Public Function HiByte(ByVal wParam As Integer) As Byte
'note: VB4-32 users should declare this function As Integer
HiByte = (wParam And &HFF00&) \ (&H100)
End Function
Public Function LoByte(ByVal wParam As Integer) As Byte
'note: VB4-32 users should declare this function As Integer
LoByte = wParam And &HFF&
End Function
Public Function HiWord(wParam As Long) As Integer
If wParam And &H80000000 Then
HiWord = (wParam \ 65535) - 1
Else
HiWord = wParam \ 65535
End If
End Function
Public Function LoWord(wParam As Long) As Integer
If wParam And &H8000& Then
LoWord = &H8000& Or (wParam And &H7FFF&)
Else
LoWord = wParam And &HFFFF&
End If
End Function
Public Function LoWordCM(wParam As Long) As Integer
'using API
CopyMemory LoWordCM, wParam, 2
End Function
Public Function LShiftWord(ByVal w As Integer, ByVal c As Integer) As Integer
Dim dw As Long
dw = w * (2 ^ c)
If dw And &H8000& Then
LShiftWord = CInt(dw And &H7FFF&) Or &H8000&
Else
LShiftWord = dw And &HFFFF&
End If
End Function
Public Function RShiftWord(ByVal w As Integer, ByVal c As Integer) As Integer
Dim dw As Long
If c = 0 Then
RShiftWord = w
Else
dw = w And &HFFFF&
dw = dw \ (2 ^ c)
RShiftWord = dw And &HFFFF&
End If
End Function
Public Function MakeWord(ByVal bHi As Byte, ByVal bLo As Byte) As Integer
If bHi And &H80 Then
MakeWord = (((bHi And &H7F) * 256) + bLo) Or &H8000&
Else
MakeWord = (bHi * 256) + bLo
End If
End Function
Public Function MakeDWord(wHi As Integer, wLo As Integer) As Long
If wHi And &H8000& Then
MakeDWord = (((wHi And &H7FFF&) * 65536) Or _
(wLo And &HFFFF&)) Or &H80000000
Else
MakeDWord = (wHi * 65535) + wLo
End If
End Function
Public Function MAKELONG(wLow As Long, wHigh As Long) As Long
MAKELONG = LoWord(wLow) Or (&H10000 * LoWord(wHigh))
End Function
Public Function MAKELPARAM(wLow As Long, wHigh As Long) As Long
'Combines two integers into a long integer
MAKELPARAM = MAKELONG(wLow, wHigh)
End Function