Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I need to write a program to create a rectangle on desktop, which will selects any portion of the desktop (It may include complete screen) and then I need to capture that portion. I know about capturing, but I don't which windows APIs I need to use to draw selection rectangle.

I am using c++ and vc++ compiler.

Please suggest me how to execute this task. If you have any links or respective code, give those.

Awaiting for your reply.... Thanks in advance....
Posted

Well, you did tag it appropriately, the WinGDI would allow you to do that.

There are plenty of articles here at CP:
http://www.codeproject.com/KB/GDI/[^]
 
Share this answer
 
See this recent question:

How can I take a screenshot of a single CWnd object?[^]

The original poster posted his code for taking a screenshot of the entire screen.

That code will work to also take a screenshot of some smaller rectangle on the screen, if you change the width and height of the destination bitmap and the offset and width and height in the bitblt() call.
 
Share this answer
 
Hi all,

Thanks for your solutions.....I got a code to draw a rectangle by tracking mouse messages. I need to know how to handle mouse or keyboard messages posted by mouse movement anywhere on desktop even if it is on other windows. Only I know how to handle messages specific to a window. Please suggest me in right direction....

Awaiting for your reply.... Thanks in advance...

Anand
 
Share this answer
 
for such code, you have to store data about each and every bit on ur screen in the program

once you have all records about every point on the screen

use mouse drag code with data about starting and final points on the mouse click.

when you have the rectangular area generated by the mouse, you can extract the required one...

Its easy to do, but demands more efforts for this simple code..

so, best of luck... :)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900