How do you get them?
These dont work.Code:while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
cout << Msg.(&pt) <<"\n";
or
cout << Msg->pt <<"\n";
Printable View
How do you get them?
These dont work.Code:while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
cout << Msg.(&pt) <<"\n";
or
cout << Msg->pt <<"\n";
Usually you process messages in the callback.
Would be easier if you gave more detail of what you want to do (you seem unfamilar with event driven apps). The while loop you posted is a 'message pump'. The only time that while loop ends is when the app closes.
If you just want to get the current mouse position use GetCursorPos().
[note that the point returned is in screen coords]
The trouble is knowing when you need to get the pos....
Thank you Novocain!
Yeah thats ok im just checking out the messages sent to the window just for fun.
I could check out
and all the rest in the MSG structure except im having trouble with pt.Code:cout << Msg.wParam <<"\n";
So i guess i should know if it has two or four coordinates, its not said on msdn.
MSG Structure ()
Each message has different values sent in the wParam and lParam.
Generally mouse click coord are in the lParam, two ints 'packed' into the DWORD. You have to check what to expect from each msg as some do not send either or both.
Mouse msgs are generally client coords (0,0 is the top left of your dialog, not the screen).
Code://for WM_LBUTTONDOWN etc
cout << LOWORD(msg.lParam) <<" \n"; //or GET_X_LPARAM()
cout << HIWORD(msg.lParam) <<" \n";
Thanks to you!