Discussion:
SetMapMode and MouseMove messages
(too old to reply)
Jack
2010-01-18 09:22:31 UTC
Permalink
Hi,

case WM_PAINT:
hDC = BeginPaint(hWnd, &PaintStruct);

SetMapMode(hDC, MM_ISOTROPIC);
SetWindowExtEx(hDC, 450,450,NULL);
SetViewportExtEx(hDC, cxClient, -cyClient, NULL);
SetViewportOrgEx(hDC, 0, cyClient, NULL);
//[snip]
...
case WM_MOUSEMOVE:
int xPos, yPos;
xPos = LOWORD(lParam);
yPos = HIWORD(lParam);
char buff[80];
sprintf (buff, "%d", xPos);
SetWindowText(editField, buff);
sprintf (buff, "%d", yPos);
SetWindowText(editField2, buff);
break;
//..

I am wondering how I can make SetWindowText report the correct coordinates
as I am using the mapping mode which starts from the lower-left corner.
Currently, +ve x goes to the right and +ve y goes downwards. I'd like to
have +ve goes upwards and
starts from the lower-left corner.
Thanks
Jack
Igor Tandetnik
2010-01-18 16:55:22 UTC
Permalink
Post by Jack
I am wondering how I can make SetWindowText report the correct coordinates
as I am using the mapping mode which starts from the lower-left corner.
WM_MOUSEMOVE always reports physical pixels. You could use DPtoLP to convert them to logical coordinates, or just do the math yourself.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
Jack
2010-01-19 08:01:34 UTC
Permalink
Thanks
I finally used this
lets say the client height = 480
yPos = 480-yPos;
Think it works
Jack

Loading...