They can be used with OnMessage() to format something like coordinates from LParam.
Ore format any other 32Bit integer structured as low high bit order.
HIWORD:
LOWORD:
MAKELONG:
EXAMPLE:
Return Highword as hexadecimal.
HIWORD(0x3200258,1)
Return Low Word as integer.
LOWORD(0x3200258)
Return Dword as hexadecimal. The LOWORD and HIWORD parameters
need to be 16bit Integers!
MAKELONG(600,800, 1)
This table might help to make some sense from all of this.
._________________________________________.
|_1_______8|9______16|17_____24|25______32||
|11 00 10 00.00 00 00 00.10 01 01 10.00 00 10 00|| = 32 bits.
|31_8bit___|_8bit_____|_8bit_____|_8bit____ 0|| -> Bit 0-31.
| __msb___+_next_msb|_next_lsb_+_lsb_______|| Most and Least Significant Bit.
| __BYTE4_+_BYTE3___+_BYTE2___+_BYTE1____|| = 4 Byte / 4x8 bit.
| _____HIWORD_______|_____LOWORD________|| = 2 Word / 2x16 bit
| ________________DWORD__________________|| = 1 Dword = 2 Word = 4 Byte = 1x32 bit.
.
Download below: .
Code: Select all
; Return the first two bytes in a 32 bit integer. MSB
HIWORD(Dword,Hex=0){
BITS:=0x10,WORD:=0xFFFF
return (!Hex)?((Dword>>BITS)&WORD):Format("{1:#x}",((Dword>>BITS)&WORD))
}
; Return the second two bytes in a 32bit Integer. LSB
LOWORD(Dword,Hex=0){
WORD:=0xFFFF
Return (!Hex)?(Dword&WORD):Format("{1:#x}",(Dword&WORD))
}
; Combine two WORD, to make one DWORD.
MAKELONG(LOWORD,HIWORD,Hex=0){
BITS:=0x10,WORD:=0xFFFF
return (!Hex)?((HIWORD<<BITS)|(LOWORD&WORD)):Format("{1:#x}",((HIWORD<<BITS)|(LOWORD&WORD)))
}
/* <-- Remove ore comment out this line, then run the script to test it!
Dword := 0x3200258
MsgBox % "Integer`t`t`tHexadecimal`n"
. "-----------------------------------------`n"
. "" HIWORD(Dword) "`t`t`t" HIWORD(Dword, 1) "`n"
. "" LOWORD(Dword) "`t`t`t" LOWORD(Dword, 1) "`n"
. "" MAKELONG(LOWORD(Dword), HIWORD(Dword)) "`t`t`t" MAKELONG(LOWORD(Dword), HIWORD(Dword) , 1) "`n`n"
. "X = " HIWORD(Dword) "`n"
. "Y = " LOWORD(Dword) "`n"