2

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

Kay
  • 845
  • 7
  • 21
  • 33
  • I don't understand why you think `PrintWindow` is failing. The way I understand your question, that should do exactly what you want. I'm not really sure what you mean when you describe VNC as "continuously repainting windows". – Cody Gray - on strike Apr 29 '11 at 12:50
  • @Cody - that's what I thought too until I tried it `PrintWindow(handle, hDC, 0);` - it failed to capture an image when I minimised an RDP connection to my windows XP machine. It works when RDP is not minimised. I thought I could capture the window image from memory but all it produced was a window with the insides black. I tried it for different types of windows (notepad, calc). I then installed VNC and I closed the VNC viewer and it worked each time. It some how gets windows to render even if the user is inactive. – Kay Apr 29 '11 at 14:25

2 Answers2

2

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.

user703016
  • 37,307
  • 8
  • 87
  • 112
  • Very interesting, I need to read up on it first, I don't want to go all out yet! – Kay Apr 29 '11 at 14:27
0

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

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • Hmm, you're drawing a different conclusion than the one which is drawn by the answers to the questions you link to. You're right that VNC doesn't send `WM_PAINT` messages, but that doesn't imply that Windows sends this message when a user is not active. The solutions to those other questions either involve `PrintWindow`, or taking advantage of the new painting features introduced with DWM. – Cody Gray - on strike Apr 29 '11 at 13:04