Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC
Hello..
 
Am having a window handle(hwnd). I want to take Screenshot of this window, I have used PrintWindow for this like this:
 
void Screenshot()
{
  CImage image;
  image.Create(imageWidth, imageHeight, 24);
  CImageDC imageDC(image);
 
  HWND hwnd = ::FindWindow(0,"MyWindow");
 
  PrintWindow(hwnd, imageDC, PW_CLIENTONLY);
 
  image.Save("H:\\Image.bmp",ImageFormatBMP);
}
 
With this code i get the specified window image in H:\\ drive. Now my question is : How do i take a screenshot of MyWindow with user specified area i.e., by specifying x-axis & y-axis. I mean, i don't want the entire image of MyWindow, I need only specified area of MyWindow i.e., Somewhere in the middle of MyWindow.
So How do i specify x & y coordinates to PrintWindow. Alternatively. i have tried with BitBlt & StretchBlt but they are relatively slower than PrintWindow.
Please someone can tell how to accomplish this.
 
Thank you all Smile | :)
Posted 13-Feb-13 23:22pm
Guru_C++1.2K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You would need to write your own code to handle the WM_PRINT message[^].
  Permalink  
Comments
Guru_C++ at 14-Feb-13 5:50am
   
How to write that WM_PRININT messages. I dont have any idea about that..
Richard MacCutchan at 14-Feb-13 6:01am
   
You just need to take the parameters passed in with the message and draw the contents of your window using that device context. Follow the link above to the documentation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100