MFC dialog screenshot to .bmp file

Hi guys can someone show me a sample code. How can I make a screenshot of mfc dialog client area and save it as a .bmp file ? So far I just get weird results i.e. black or white screen but the shape and size are right, just can't see the content as I said. Please help. THank you.
Last edited on
What have you tried so far?
No point posting links you maybe have tried already.
I did hit problems trying to grab a "screen shot" of an individual window not so long ago; the bitmap was the right size but totally black.

What I was doing was acquiring the DC for the window (GetWindowDC) and the using the usual CreateCompatibleDC, CreateCompatibleBitmap, BitBlt approach to capture a bitmap. Which was all black.

But the same approach worked fine to grab the whole screen. So I ended up acquiring the DC for the whole screen -- using GetDC(NULL) -- and the just BitBlt-ing the area I was interested in into the bitmap (for me this was the whole window, including the border and menu, but could just as easily be the client area.)

Andy

PS I didn't investigate the problem any further, but my problem with the DC obtained with GetWindowDC might be something to do with the way the Desktop Windows Manager (DWM) does its compositing.
Last edited on
closed account (E0p9LyTq)
https://stackoverflow.com/questions/3291167/how-can-i-take-a-screenshot-in-a-windows-application
hello!!!
I want to how can i made screen short of MFC Dialogue client location to save to .bmp any Idea about this please let me know!!!!!!


closed account (E0p9LyTq)
I want to how

Did you do an internet search? Amazing what I found when I did one.

If it can be done using the Win32 API and C/C++, it can be done using MFC.
http://msdn.microsoft.com/en-us/library/dd183402(v=vs.85).aspx

There are ways to save a screen shot as a JPEG.
http://stackoverflow.com/questions/997175/how-can-i-take-a-screenshot-and-save-it-as-jpeg-on-windows
Topic archived. No new replies allowed.