locking the mouse to the window
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
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.
I got ClipCursor to work fine. Try this:
jfl.
RECT Old, New = { 20, 20, 200, 200 }; // Get old clipping rect GetClipCursor( &Old ); // Set new clipping rect ClipCursor( &New ); // cleanup ClipCursor( &Old );
jfl.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement