LOBYTE, HIBYTE, HIWORD, LOWORD. What does these terms means? I am new to these stuff and msdn doesn provide much information about those stuff.. Please teach me..
THank YOu @!
Printable View
LOBYTE, HIBYTE, HIWORD, LOWORD. What does these terms means? I am new to these stuff and msdn doesn provide much information about those stuff.. Please teach me..
THank YOu @!
They are macros.
#define LOWORD(l) ((WORD)(l))
#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
#define LOBYTE(w) ((BYTE)(w))
#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
LOWORD gets the lower two bytes of a 4 byte value and so on.
I got that in msdn and I still couldn understand it? Do you have any sample?
THank YOu @!
Before I give out samples tell me this
given an integer 0x12345678
what are the two lower bytes of that intger?
what are the two higher bytes of that integer?
given a short value 0xABCD
what is the low byte of that value?
what is the high byte of that value?
plain and simple: the function helps you to get the lowest/highest byte/word of a bigger value:
an example:
#define DIGIT 0xFFAC
// I am flipping stuff today, so do not care if I flipped they two too
LOBYTE(DIGIT) == 0xAC
HIBYTE(DIGIT) == 0xFF
Get it?
p.s.: Sory for not using the code tag, but my MacExplorer cannot show the correctly
I really don know... Sorry.. But now thanks to NoHero... I understand what it means...Quote:
Originally Posted by UnderDog
You know what, I got a sample source code which talk about send a key on keyboard through SendMessage().. From the source code I found this:
BYTE ScanCode = LOBYTE(::MapVirtualKey(VKey, 0));
What does it try to do? Is that means MapVirtualKey() will have LOBTYE and HIBYTE?
OK wait! before I learn SendMessage(), I always confuse the use of WPARAM and LPARAM, until now I know that LOWORD(WPARAM) is refering to the control ID and HIWORD(WPARAM) is refering to the notification message whereas LPARAM is the event.. Am I right? Please correct me if I am wrong..
Then does that case is same to this case.. I mean LOBYTE will refering to some ID control and then HIBYTE will refering to the notification message? Please corect me..
THank YOu @!
The meaning of the WPARAM and LPARAM parameters will be different, depending on which message you are handling. You will need to consult MSDN for an explanation of what WPARAM and LPARAM respresent.
Each of them is two words (double-word or DWORD) in size. Sometimes, a DWORD is necessary to hold a message parameter. Other times, like in the example you mentioned, a word will suffice. In that case, like in the WM_COMMAND message, two parameters (the control ID and the notificaiton code) which are each a word, can be packed together into a DWORD-sized WPARAM. This can be accomplished by using the MAKEWPARAM (or MAKELPARAM) macros. Using both macros, you can now pass up to four word-sized parameters with a message.
However, it's up to the client (you) to extract the DWORD values into WORD values. This is done with the LOWORD/HIWORD macros.
Hi!! Thanks for your explanation... I feel so happy.. :)
So... Hmm~ ... Then how about LOBYTE as I mention in the example? Will that case is actually the same as WPARAM/LPARAM?
THank YOu @!
No. Remember, those are DWORD's. The LOBYTE macros returns a byte from a WORD.Quote:
Originally Posted by huahsin68
So, if you have a DWORD (like WPARAM/LPARAM), you should use the LOWORD/HIWORD macros to retrieve a pair of 16-bit words from a single 32-bit DWORD.Code:BYTE = 8 bits
WORD = 16 bits
DWORD = 32 bits
If you have a 16-bit WORD and need the two 8-bit BYTEs that make up that word, then you'll use LOBYTE/HIBYTE to retrieve them.
Thanks Bond, the infermation you have posted here was very usefulQuote:
Originally Posted by Bond
Great !
Wow, this post is a blast from the past. Glad you found the information useful!Quote:
Originally Posted by omkarhm
Practice safe programming.