Public Function GET_X_LPARAM (ByVal lParam As Long) As Long
Dim hexstr As String
hexstr = Right("00000000" & Hex(lParam), 8)
GET_X_LPARAM = CLng("&H" & Right(hexstr, 4))
End Function
The GET_X_LPARAM macro extracts the x-coordinate from a 32-bit integer packed with a coordinate pair. The macro retrieves the value found in the value's low-order word, which in this case represents the x-coordinate.
The macro returns the x-coordinate of the packed coordinate pair.
The method I present for extracting the low-order word may seem unusual, since I first convert the value into an 8-digit hex string and then cut that in half. I do this because it is the only way that works 100% of the time in Visual Basic. All the math-based routines I've seen to do this fail when the &H80000000 bit of lParam is set, because VB then sees it as a negative number.
Back to the Macro list.
Back to the Reference section.
Last Modified: July 30, 2000
This page is copyright © 2000 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/get_x_lparam.html