Click to See Complete Forum and Search --> : How to get the cursor position?


Aparna
April 6th, 1999, 04:40 AM
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.

Lyu ABE
April 6th, 1999, 04:47 AM
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).

Lyu ABE
April 6th, 1999, 04:48 AM
... Other mouse functions also return the same info, for example OnLButtonDown (UINT nFlags, CPoint point)...

Aparna
April 6th, 1999, 05:12 AM
Hi,
Thanx for the reply. But can u tell me how do i get the cursor position WM_KEYDOWN message handler.

Thanks,
Aparna

Lyu ABE
April 6th, 1999, 06:51 AM
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...