# GS

posts - 19, comments - 3, trackbacks - 0, articles - 8
::  ::  ::  ::  ::

## Remarks

Use the following code to obtain the horizontal and vertical position:

xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);



As noted above, the x-coordinate is in the low-order short of the return value; the y-coordinate is in the high-order short (both represent signed values because they can take negative values on systems with multiple monitors). If the return value is assigned to a variable, you can use the MAKEPOINTS macro to obtain a POINTS structure from the return value. You can also use the GET_X_LPARAM or GET_Y_LPARAM macro to extract the x- or y-coordinate.

Important  Do not use the LOWORD or HIWORD macros to extract the x- and y- coordinates of the cursor position because these macros return incorrect results on systems with multiple monitors. Systems with multiple monitors can have negative x- and y- coordinates, and LOWORD and HIWORD treat the coordinates as unsigned quantities.

LMousePt.X := SmallInt(Msg.LParamLo);
LMousePt.Y := SmallInt(Msg.LParamHi);

//或者

LMousePt.X := SmallInt(Msg.LParam);
LMousePt.Y := (SmallInt)HiWord(Msg.LParam);