Archived

This topic is now archived and is closed to further replies.

how to do a Mouse drag in direct input

This topic is 5009 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, I''m using the mouse direct input in the NeheGL basecode for my OpenGL project. This is what I am doing switch (uMsg) // Evaluate Window Message { case WM_MOUSEMOVE: MouseX = (GLfloat)LOWORD(lParam); MouseY = (GLfloat)HIWORD(lParam); //isClicked = (LOWORD(wParam) & MK_LBUTTON) ? true : false; //isRClicked = (LOWORD(wParam) & MK_RBUTTON) ? true : false; break; case WM_LBUTTONUP: isClicked = false; DetectMouseClickUp(); break; case WM_RBUTTONUP: isRClicked = false; break; case WM_LBUTTONDOWN: isClicked = true; DetectMouseClick(); break; case WM_RBUTTONDOWN: isRClicked = true; break; case WM_ERASEBKGND: //Check to see if Windows is trying to erase the background return 0; How do I detect a mouse drag or how do I get the X and Y while the mouse button is down... note: I am only using ORTHO

Share this post


Link to post
Share on other sites
While processing the WM_MOUSEMOVE, the wParam contains flags about which mouse buttons are pressed. So if you receive a WM_LBUTTONDOWN message before the WM_MOUSEMOVE message, you know that the user is dragging the mouse with the left button down. It looks like you have this commented out in your code.

---
K-1 Productions: Come visit us here.

Share this post


Link to post
Share on other sites
Hey actually i do the same thing but i only use the left button in my program but that doesnt matter. As soon as you move ur mouse it sends a WM_MOUSEMOVE call and in ur case it changes the MouseX and MouseY variables. If u want them to change only when u click on left mouse put a condition before and call a fonction that will change your image''s coordonate to drag ur image for example. U could do this:

switch (uMsg) // Evaluate Window Message
{
case WM_MOUSEMOVE:
if( isClicked ){
MouseX = (GLfloat)LOWORD(lParam);
MouseY = (GLfloat)HIWORD(lParam);
drag_my_image( MouseX, MouseY );//unless ur variables are global you dont have 2 do that: u put a condition in ur drag_my_image() fonction if( isClicked ) etc...
}
break;
case WM_LBUTTONUP:
isClicked = false;
DetectMouseClickUp();
break;
case WM_RBUTTONUP:
isRClicked = false;
break;
case WM_LBUTTONDOWN:
isClicked = true;
DetectMouseClick();
break;
case WM_RBUTTONDOWN:
isRClicked = true;
break;

case WM_ERASEBKGND: //Check to see if Windows is trying to erase the background
return 0;

Share this post


Link to post
Share on other sites