Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Prevent cursor from leaving box.

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

Thanx.
0
Comment
Question by:yep090598
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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!

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 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