Advertisement

Mouse Probs.

Started by April 01, 2000 09:43 PM
0 comments, last by Blue*Omega 24 years, 7 months ago
Hi! I''m new to this forum but what I''ve seen so far has been VERY helpful... So I was wondering if anyone knew the answer to my problem. In my little engine i have a routine set up to capture mouse movement and clicks. Here''s the code. case WM_MOUSEMOVE: mousex = LOWORD (lParam) - 400; mousey = HIWORD (lParam) - 300; mouseclk = wParam; //SetCursorPos (400, 300); break; This works fine but... If I un-comment the SetCursor my program crashes! I want to set up a Quake II/III style console so I am trying to get the mouse to recenter it''s self whenever it is moved (by the way, this program runs in 800x600). I just don''t know how to get the mouse to center without SetCursor! Can anyone help me??? Blue*Omega :)
// Tojiart
Okay,
Let's See here:

case WM_MOUSEMOVE:
mousex = LOWORD(lParam) - 400;
mousey = HIWORD(lParam) - 300;
mouseclk = wParam;
SetCursorPos(400,300);
break;

I assume you are letting Windows "blit" your cursor for you.

Hence: Whenever you call SetCursorPos() it sends the WM_MOUSEMOVE call to your app, resulting in a never ending loop. (I think)

Thus this code should fix it:
case WM_MOUSEMOVE:
mousex = LOWORD(lParam) - 400;
mousey = HIWORD(lParam) - 300;
mouseclk = wParam;
if ((LOWORD(lParam) != 400) /* OR MARKS */ // (HIWORD(lParam) != 300))
SetCursorPos(400,300);
break;


Edited by - Big Al on 4/3/00 2:51:09 AM

This topic is closed to new replies.

Advertisement