Click here to Skip to main content
11,926,961 members (53,782 online)
Rate this:
Please Sign up or sign in to vote.
See more: MFC

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);

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

1 solution

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

Solution 1

You would need to write your own code to handle the WM_PRINT message[^].
Guru_C++ 14-Feb-13 5:50am
How to write that WM_PRININT messages. I dont have any idea about that..
Richard MacCutchan 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2015
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