|
-
July 19th, 2004, 05:21 AM
#1
what is HIBYTE, LOBYTE, HIWORD, LOWORD
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 @!
-
July 19th, 2004, 05:24 AM
#2
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.
Say no to supplying ready made code for homework/work assignments!!
Please rate this post!
-
July 19th, 2004, 05:33 AM
#3
I got that in msdn and I still couldn understand it? Do you have any sample?
THank YOu @!
-
July 19th, 2004, 05:45 AM
#4
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?
Say no to supplying ready made code for homework/work assignments!!
Please rate this post!
-
July 19th, 2004, 05:56 AM
#5
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
-
July 19th, 2004, 06:21 AM
#6
 Originally Posted by UnderDog
Before I give out samples tell me this
given an integer 0x12345678
..
..
given a short value 0xABCD
..
..
I really don know... Sorry.. But now thanks to NoHero... I understand what it means...
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 @!
-
July 19th, 2004, 07:56 AM
#7
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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-
July 19th, 2004, 09:03 PM
#8
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 @!
-
July 20th, 2004, 07:19 AM
#9
 Originally Posted by huahsin68
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.
Code:
BYTE = 8 bits
WORD = 16 bits
DWORD = 32 bits
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.
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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-
March 22nd, 2007, 01:03 AM
#10
Re: what is HIBYTE, LOBYTE, HIWORD, LOWORD
 Originally Posted by Bond
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.
Thanks Bond, the infermation you have posted here was very useful
Great !
-
April 9th, 2007, 01:48 PM
#11
Re: what is HIBYTE, LOBYTE, HIWORD, LOWORD
 Originally Posted by omkarhm
Thanks Bond, the infermation you have posted here was very useful
Great !
Wow, this post is a blast from the past. Glad you found the information useful!
Practice safe programming.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|