Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Prevent cursor from leaving box.

Posted on 1998-10-18
4
Medium Priority
?
174 Views
Last Modified: 2013-11-20
How do I prevent the cursor from leaving my dialog box?

Thanx.
0
Comment
Question by:yep090598
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 800 total points
ID: 1323501
Use the function ClipCursor to prevent the cursor from leaving a specified rectangle.  Make sure you call the function again when your program exits, otherwise the cursor will remain boxed in! :-)

If you have any further questions regarding this issue, please feel free to ask.  Thanks!
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1323502
Just to help thresh out here...

Get your entire dialog's dimension by calling

CRect rcClient;
GetClientRect( &rcClient );

Then keep the cursor locked within your boundaries...

ClipRect( rcClient );

then to free it up

ClipRect( NULL );

Note that GetClientRect will only get the client region (it's what you want).  The Non-Client area such as the toolbar and the minimize/maximize buttons are not included in this area so the cursor will be locked within the bounds of the drawing area.

Phillip
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1323503
Thanks for elaborating Phillip.  I was going to, but then I had to go outside and do some junk around the house (right then of course).  And then I fogot about it :-(

ADK - If you have any other questions, please ask.  But I think Phillip covered them all :-)
0
 

Author Comment

by:yep090598
ID: 1323504
Hey thanks thresher_shark and Phillip!  The solution works great.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question