Advertisement

Mouse click ?? (direct input)

Started by November 10, 2000 04:48 PM
0 comments, last by J-W 24 years ago
Hello! I''ve got a little problem with the mouse ''clic detection'' I know how to use the mouse (from lesson 23) I''ve tried something like this POINT mpos; bool mouseclick; ... and in Winmain() in the while() loop of course: SwapBuffers(hDC); // Swap Buffers (Double Buffering) GetCursorPos(&mpos); // get mouse position etc. And that all works fine... but this is what I added in WndProc: case WM_KEYUP: // Has A Key Been Released? { keys[wParam] = FALSE; return 0; // Jump Back } case WM_LBUTTONDOWN: { mousekey = TRUE; } case WM_LBUTTONUP: { mousekey = FALSE; } And than when I ad in the DrawGLscene ''loop'' the following code: if(mouseclick) blah... //do something But this doesn''t work.... Maybe I''m doing everything wrong but can someone please tell me how I can make my program detect a (left or right) mouseclick? thanx
____ __ __/ _` / / /_ _ ___ _ ___ /_/_ /___ __/___ __ L /__/ _//__/ _/ ____/ _ _ /___/ /_/ /_/rulez
Catch the WM_MBUTTONDOWN and WM_MBUTTONUP messages.
wParam will contain the button pressed/released, like so:

Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.

Also, if you want it xPos = LOWORD(lParam) and yPos = HIWORD(lParam).

Hope this helps

This topic is closed to new replies.

Advertisement