0

for some reason, I need to capture the screen of one application automatically, and I find one good example from link How to get screenshot of a window as bitmap object in C++?

During my test, I found a strange thing (my test is based on Windows 10 with Visual C++ 2008):

  • in application of Windows notepad, I have to use parameter WM_PRINTCLIENT, or the captured is all black

    PrintWindow(hwnd, hdc, WM_PRINTCLIENT);
    
  • in application that I want to capture, I have to use PW_CLIENTONLY, or the captured is all black

    PrintWindow(hwnd, hdc, PW_CLIENTONLY);
    

So my question is that: what's the difference between them, and is there any rules? I tried to searching it in Internet but didn't find good hint.

Community
  • 1
  • 1
Kevin SUN
  • 158
  • 1
  • 7
  • 3
    You are not passing a correct value for the 3rd argument. It must be 0 (entire window) or PW_CLIENTONLY (client area). What happens next entirely depends on how much work the programmer did to implement WM_PRINT and WM_PRINTCLIENT. Always be prepared to be disappointed. – Hans Passant Sep 05 '16 at 06:58
  • @HansPassant, thanks a lot for your help. I tested parameter 0 works for both my target application and notepad. – Kevin SUN Sep 05 '16 at 23:05

0 Answers0