How does VNC send REPAINT messages to windows even when a user is not active?
I would like to implement this in C sharp - I've had a look at the PrintWindow, SendMessage methods and none of them achieve the same thing as VNC (tested by capturing images and its black) but with VNC I get the full picture.
What techniques are they using to do this and can this be implemented in C sharp to get windows to always repaint even when a user is not active (i.e. RDP is closed, minimised or similar).
Thanks all
You could use the technique used by video games, which consists in redrawing permanently a window during CPU idle time.
I found a C# implementation here.
You just have to adapt it to your needs.
VNC does NOT send WM_PAINT messages
Windows does (and it does not care whether a user is active). See also
Is it possible to screenshot a minimized application
How to get the screenshot of a minimized application programmatically?
Capturing screenshots of a minimized remote desktop
Related
How can I detect on Windows OS level when any of my desktop application window is screen shared by any screen sharing tool. I am sure any screen sharing tool can not do screen sharing to remote user without support from Windows OS. I want to know what is that "something" which is set/done when any desktop app window is screen shared. I am writing a desktop app and want to behave differently when my app window is screen shared. I am looking for a generic solution and not specific to screen sharing tool. Any pointer to detect it manually or code snippet around this will be of great help. Thank you.
I am working on examination system, as a security part of the system I don't want anyone should leak the paper by screen recording or by giving remote using so many free applications for desktop sharing.
First I searched for can I block such applications? But I don't think so, as there so many ways to record/share a screen. Then I got to know about HDCP but I guess it will only application to videos and not to HTML (correct me if I am wrong). SO I want something like HDCP or VLC player's "directx video output" so that content doesn't get captured by printscreen or other screen capture techniques.
I guess D3D9/DDraw overlays are only for video content can I use this for HTML content/in a c# based windows application?
I have achieved this by using SetWindowDisplayAffinity, as per MSDN
The display affinity setting. This setting specifies where the window's contents are can be displayed. Set this value to WDA_MONITOR to display the window's contents only on a monitor. Set this value to WDA_NONE to remove the monitor-only affinity.
So setting WDA_MONITOR to handle of WinForm makes it black when print screen or desktop recording or in desktop sharing application.
Image captured through mobile:
However, I am open for any other (better) answer for this.
Is there some event or notification I can receive or hook each time an external LCD monitor is plugged in or unplugged from a laptop running Windows 7?
The laptop detects this and switches my display to the external screen and back with certain kinds of resizing or repositioning but is this exposed by the operating system so that applications can provide a handler, attach a script, etc?
If not, is there a registry setting or API I could poll from time to time?
(I prefer programming C + Win32 API)
UPDATE
Mike's answer below, WM_DEVICECHANGE led me to RegisterDeviceNotification(), but I'm struggling to implement it so far...
UPDATE 2
This question has been asked with different wording a couple of times, but not fully answered yet in my opinion:
How to detect hot plugging of monitor in a win32 application?
Getting an event on monitor hotplug for windows
According to this article Windows sends the WM_DISPLAYCHANGE message when display resolution changes and also when a display is added or removed.
If you need to react to desktop size changes due to monitor addition or removal, you can do so in the handler of this message. The LPARAM gives you the new resolution of the display on which the window is located. Notice that this resolution will be scaled if you use anything else than 100% for system DPI scaling and your program is not DPI-aware.
Alternatively use the EnumDisplayMonitors function to get the display resolution for each connected monitor and the relative positions of the monitors in the virtual desktop. This functions uses the real device pixel values regardless of DPI scaling.
You can try WM_DEVICECHANGE. If that doesn't do the trick, run your window and attach Spy++ to it which will log all the window messages it receives. Then plug your monitor in and check if you received any messages.
Alternatively you can poll GetSystemMetrics() with SM_CMONITORS.
As said here:
You will see registered messages "UxdDisplayChangeMessage" and "HotplugDetected" (second one only when adding monitor). You can use RegisterWindowMessage to get the identifier for these messages.
There are also other messages you can check, just see the linked answer.
I would like to use a monitor which is actually marked "disconnected" in the windows control panel under "Change display settings". (I do NOT mean a physically disconnected monitor.)
I know how to add a second monitor in Windows and make it part of desktop. I also know how to make my application run on a primary or on secondary monitor when they are part of desktop.
I have a piece of equipment attached to the PC which has a touch screen on it. The touchscreen is connected to the PC over USB looking as an ordinary USB-Monitor and I can make it part of my Windows desktop. But that is not what I want.
What I would like to do is make sure that only one special application can run on this monitor. I also do not want to have a windows desktop on it because than the user could move any window to it which is not what I want. The idea behind all this is to use the touch screen to have an application on it which can control this external piece of equipment. The user would only have to run the PC but not to login. I was thinking about starting the app from a windows service before the windows desktop is loaded. And once the user logs in I do not want him to be able to use the touch screen for anything else except this special application. That is why the touch screen must not be part of the windows desktop but ”deactivated”.
I am using . NET 4.0 and C# for my application, but I will use C++ or whatever comes handy.
Any help or idea is appreciated. Thank you!
It seems WDDM does not support independent displays any more. Here are a few links in case somebody wishes to take a look for himself:
(old MSDN link) = /windows/win32/gdi/multiple-display-monitors
(old MSDN link) = /windows/win32/gdi/using-multiple-monitors-as-independent-displays
The important part is this note from the second link:
ⓘ Note
Using other monitors as independent displays isn't supported on drivers that are implemented to the Windows Display Driver Model (WDDM).
I am wondering if it is possible to create an application that could receive a notification when any other application/window is docked with the new windows 7 docking feature (f.ex. Winkey + left arrow)
The purpose of my application would be to set up custom rules for certain windows. So for example if I am using Chrome and I press the Win+LEFT keys, then my application would receive a notification, and would be able to say that the window should not resize to 50% of the screen, but should use 70%.
I am not very familiar with writing windows applications (mostly do web), so any pointers at how this might be achieved are very welcome.
Thanks.
Given the Win+Left/Right combinations work with applications that pre-date Windows 7 I strongly suspect it is just a combination of WM_SIZE and WM_MOVE messages with coordinates worked out by the shell, and there is nothing to directly distinguish such a resize from any other within the application.
Use Spy++ from the SDK to prove this.
You could apply heuristics based on the screen size to detect these events.