Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

How to reset Mouse Postion in Visual C++ 6

Hi expert!
 In my project I have  to draw Polygons. I laid out them in a StaticText. and my problem is how to prevent mouse from moving out the Static Text if a polygon isn't drawn completely. (in order to draw a polygon.I choose several Point and  drawing polygon is complete if the last  point  coincide the firstpoint).
Thanks for help
 
 
0
trung85gn
Asked:
trung85gn
  • 2
1 Solution
 
jimstarCommented:
You want to set the mouse capture, so that you can get mouse messages from all windows in the system. Then, in your message processing function, you want to check the coordinates of the mouse, and if it isn't within your predetermined region, you can set the mouse position back to the region. This has the effect of keeping the mouse within your region, similar to how maximum window size is implemented.

More information on mouse capture:
http://www.codeproject.com/gdi/mousecapture.asp
0
 
jimstarCommented:
An easier solution than my previous comment:

CRect myRect;
GetWindowRect(&myRect);
ClipCursor(&myRect);

Of course, you can get the Rect of any control, and then use that for clipping the mouse as well.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now