How to get the cursor position?
Hi,
I've created a SDI application. I've derived the CView from CRichEditView class. I've created a menu item, click on that should tell me the cursor position on the client area. I've used GetCursorPos() function. Also i've converted the coordinated to client coordinates by the function ScreenToClient().
I get a -ve value for the ' y ' coordinate. Can you please tell me how do i get the cursor position, as the +ve coordinates, for each line.
Thanks,
Aparna.
Re: How to get the cursor position?
Are you trying to get the current cursor position within the window? If yes, use the OnMouseMove (UINT nFlags, CPoint point) function which gives you the x,y cursor position within the area (point.x and point.y).
Re: How to get the cursor position?
... Other mouse functions also return the same info, for example OnLButtonDown (UINT nFlags, CPoint point)...
Re: How to get the cursor position?
Hi,
Thanx for the reply. But can u tell me how do i get the cursor position WM_KEYDOWN message handler.
Thanks,
Aparna
Re: How to get the cursor position?
I guess you should first retrieve the window's RECT structure (e.g. RECT MyRect) info (GetWindowRect) then call GetCursorPos and compute the (POINT) MyPoint.x - MyRect.left and MyPoint.y - MyRect.Top coordinates...