Solved

Prevent cursor from leaving box.

Posted on 1998-10-18
4
140 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 200 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 improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now