-
Cursor Position
Quick question?
What class in MFC holds all the mouse functions if there is one????? I need to retrieve the mouse coordinates as soon as the left mouse button is pressed and set the mouse position to those same coordinates when the screen is refreshed. This is in an MFC app. Any suggestions????????
Thanks,
Kendal
-
I think the mouse message returns the coordinates of the mouse in the lparam and wparam. Not sure exactly.
-
Yup.
Code:
afx_msg void OnLButtonDown(
UINT nFlags,
CPoint point
);
The second param specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.
-
Of course you can always call into the WinAPI directly. GetCursorPos is what you want.
There IS a method of some class in MFC too, but I can't remember it.
-
Here is an addition to the question.
The GetCursorPos and SetCursorPos works, but I need to get and set the cursor position in relation to the window, not the screen. What function or method do I need to go about getting the position in the window and not the screen??????
Thanks,
Kendal
-
I am sorry.
I just realized that I should have posted this thread in the Windows Programming Forum. Forgive Me.
Kendal
-
I'm too lazy to search for the new thread now (if there is one), use ScreenToClient and ClientToScreen to convert between screen and window coordinates.
-
My responce was the name of the method in CWnd.
-
That's just a message handler Gareth. Of course he can use it to keep a constantly updated mouse position, but why when windows does it too?
-
WM_LBUTTON or OnLButtonDown WM_LBUTTONUP msgs
look at
SetCapture()
ReleaseCapture()
ClipCursor()
ect