Jump to content
  • Advertisement
Sign in to follow this  
QuadMV

locking the mouse to the window

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, when I'm in windowed mode, and I'm using the mouse to navigate, I want to force the mouse to stay in the window. I've tried: ClipCursor(&ClipArea); SetCursorPos(cx,cy); and hidecursor() For some reason, the clipcursor wasn't working right, although I expected this to do the trick. The setcursorpos seems to work, but if you move the mouse fast enough you'll see it come past the window edge at which point it could cause problems. The hidecursor works fine but that alone isn't sufficient for what I need. Should I be using clipcorsor, and should it be sufficient, or is there something else I should be calling? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Are you willing to use DirectInput? If so you can Lock the mouse in the window by using Exclusive + forground mode. then you just have to make a cursor sprite. Check out the DX Mouse Sample to see how it works.

Share this post


Link to post
Share on other sites
I got ClipCursor to work fine. Try this:

  RECT Old, New = { 20, 20, 200, 200 };

// Get old clipping rect
GetClipCursor( &Old );

// Set new clipping rect
ClipCursor( &New );

// cleanup
ClipCursor( &Old );


jfl.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!