-
mousepos
When I call this function when a button is pressed it freezes. Will this get the mouse coordinates like it is intended to do?
Code:
void getmousepos()
{
POINT p;
for(;;)
GetCursorPos(&p);
SendMessage(editbxX, WM_SETTEXT,0,(LPARAM) p.x);
SendMessage(editbxY, WM_SETTEXT,0,(LPARAM) p.y);
}
-
What you are doing might work, but there is an easier way if you are catching the mouse events. The HI and LO of the lParam is the x and the y of the mouse. So for example:
PHP Code:
case WM_LBUTTONDOWN:
SendMessage(editbxX, WM_SETTEXT,0,LOWORD(lParam)); //X Pos
SendMessage(editbxX, WM_SETTEXT,0,HIWORD(lParam)); //Y Pos
break;
-
I can't seem to get anything to work.What would you do if you wanted to get the mouse position after it moves? What functions would you use? Thanks
-
Can you give me a better example of what you want.
-
I wanted it so that when you move the mouse the coordinates are updated in the 2 editboxes. I got everything to work finally. I just used the WM_MOUSEMOVE to have it update them. Thanks anyway
-
Incidentally the reason it froze with your first code is because you were in an infinite loop and it was blocking any more messages from arriving (DispatchMessage won't return until the event handler has).