Solved

Prevent cursor from leaving box.

Posted on 1998-10-18
4
142 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix Command -- Challenging  question 7 89
wordappend challenge 8 172
Problem to event 3 95
Problem to App source 6 38
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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