locking the mouse to the window

Started by
1 comment, last by jflanglois 18 years, 8 months ago
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
3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
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.
=Loren Tapia=
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.

This topic is closed to new replies.

Advertisement