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";
This is a discussion on screen coordinates from MSG within the Windows Programming forums, part of the Platform Specific Boards category; How do you get them? Code: while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } cout << Msg.(&pt) <<"\n"; ...
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";
Using Code::Blocks with MSVC++ 2010.
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....
Last edited by novacain; 12-10-2009 at 06:14 AM.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
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 ()
Using Code::Blocks with MSVC++ 2010.
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";
Last edited by novacain; 12-10-2009 at 09:33 PM.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Thanks to you!
Using Code::Blocks with MSVC++ 2010.