GET_Y_LPARAM Macro

Public Function GET_Y_LPARAM (ByVal lParam As Long) As Long
	Dim hexstr As String
	hexstr = Right("00000000" & Hex(lParam), 8)
	GET_Y_LPARAM = CLng("&H" & Left(hexstr, 4))
End Function

Description & Usage

The GET_Y_LPARAM macro extracts the y-coordinate from a 32-bit integer packed with a coordinate pair. The macro retrieves the value found in the value's high-order word, which in this case represents the y-coordinate.

Return Value

The macro returns the y-coordinate of the packed coordinate pair.

Visual Basic-Specific Issues

The method I present for extracting the high-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.

Parameters

lParam
The packed coordinate pair to extract the y-coordinate from.

See Also

GET_X_LPARAM, MAKEPOINTS

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_y_lparam.html