Wanna explain LOWORD, HIWORD, DWORD?
Hey guys,
Newbie programmer here, working through the Lamothe book with _no_ C++ experience. Sometimes he glosses over the C++ background to this stuff, and I can''t find a good explanation anywhere (in his book, on the net, in the DX SDK help, etc.) of what the heck a LOWORD and a HIWORD are. I''m pretty sure that I''ve seen the terms DWORD and just plain WORD floating around, too.
This doesn''t have anything to do with rap, does it?
Word.
Peace, yo.
- gollum
yo homeboy, lemme bust my rhyme about dis, WORD!
basically, DWORD is some form of integer value. i think it''s something like an unsigned int, but someone correct me of i''m wrong. all HIWORD and LOWORD are are just variable types that windows uses to pass window message values to winAPI functions. or maybe not... hell i dunno, i can''t even believe myself lately...
i love leaving people in the dark...
(or is it that i''m completely unsure of my answer...)
david
basically, DWORD is some form of integer value. i think it''s something like an unsigned int, but someone correct me of i''m wrong. all HIWORD and LOWORD are are just variable types that windows uses to pass window message values to winAPI functions. or maybe not... hell i dunno, i can''t even believe myself lately...
i love leaving people in the dark...
(or is it that i''m completely unsure of my answer...)
david
HIWORD and LOWORD retreive the value of the HIWORD and LOWORD. Windows sometimes passes two values with 1 variable, HI and LO are where they are stored in the bits.
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
LOWORD and HIWORD are macros. LOWORD gets the lower 16 bits of a 32 bit integer and HIWORD gets the upper 16 bits. the wParam and lParam give you information about a particular message. This way wParam or lParam can give two pieces of information per pop. It can store one piece in the lower word and another piece in the hiword. So to reiterate LOWORD and HIWORD are macros that return the lower 16 bits of higher 16 bits of a 32 bit lParam or wParam.
I did this off the top my head so may not be 100% right.
ECKILLER
I did this off the top my head so may not be 100% right.
ECKILLER
quote:Original post by neonstar
yo homeboy, lemme bust my rhyme about dis, WORD!
basically, DWORD is some form of integer value. i think it''s something like an unsigned int, but someone correct me of i''m wrong. all HIWORD and LOWORD are are just variable types that windows uses to pass window message values to winAPI functions. or maybe not... hell i dunno, i can''t even believe myself lately...
i love leaving people in the dark...
(or is it that i''m completely unsure of my answer...)
david
DWORD is usually a long. HIWORD and LOWORD are macros or functions.
- Muzzafarath
Mad House Software
The Field Marshals
A DWORD is a 32-bit integer, and with a WORD being a 16-bit integer, the HIWORD and LOWORD refer to their respective place inside the DWORD.
<---------------DWORD--------------->
[00000000:00000000:00000000:00000000]
<-----HIWORD-----><------LOWORD----->
I''ve never delt with "LOWORD"s and "HIWORD"s, but I''m heavily into assembly, and that''s what I''m guessing they mean.
Maybe I''m wrong, but I doubt it.
When life hands you lemons, throw them at God's head.
<---------------DWORD--------------->
[00000000:00000000:00000000:00000000]
<-----HIWORD-----><------LOWORD----->
I''ve never delt with "LOWORD"s and "HIWORD"s, but I''m heavily into assembly, and that''s what I''m guessing they mean.
Maybe I''m wrong, but I doubt it.
When life hands you lemons, throw them at God's head.
Starting from the beginning:
a BIT 0 or 1
a BYTE , made from eight bits. Can hold a value of 0 to 255
a WORD, made from 2 bytes (16 bits) can hold a value of 0 to 65535. The two bytes that make up a word are called LOBYTE and HIBYTE.
If you think of the LOBYTE as the smallest part of the number, the value of a WORD is equal to 256 * HIBYTE + LOBYTE. Therefore the HIBYTE describes how many 256''s we have, and the LOBYTE describes the rest. Such is the magic of binary.
a DWORD, (double word) made from 2 words. Again referred to as LOWORD and HIWORD.
Later
Matt
Check out my project at:www.btinternet.com/~Matthew.Bennett
a BIT 0 or 1
a BYTE , made from eight bits. Can hold a value of 0 to 255
a WORD, made from 2 bytes (16 bits) can hold a value of 0 to 65535. The two bytes that make up a word are called LOBYTE and HIBYTE.
If you think of the LOBYTE as the smallest part of the number, the value of a WORD is equal to 256 * HIBYTE + LOBYTE. Therefore the HIBYTE describes how many 256''s we have, and the LOBYTE describes the rest. Such is the magic of binary.
a DWORD, (double word) made from 2 words. Again referred to as LOWORD and HIWORD.
Later
Matt
Check out my project at:www.btinternet.com/~Matthew.Bennett
I think I get the general idea. My problem is that I have to know where everything comes from.
So, let me see if I''ve got this right:
Message structures in Windows contain 32 bit integers, which for some reason are called DWORD.
There are C++(?) macros called HIWORD and LOWORD. These macros extract the first and second half of the DWORD, respectively. C++ uses those macros to get at the lparam and wparam that hold parameters for the messages.
Phew.
And this is just the beginning.
- gollum
PS - I really need to go back to Lamothe and see if he''s got the prototype for a message. Surely he does...
So, let me see if I''ve got this right:
Message structures in Windows contain 32 bit integers, which for some reason are called DWORD.
There are C++(?) macros called HIWORD and LOWORD. These macros extract the first and second half of the DWORD, respectively. C++ uses those macros to get at the lparam and wparam that hold parameters for the messages.
Phew.
And this is just the beginning.
- gollum
PS - I really need to go back to Lamothe and see if he''s got the prototype for a message. Surely he does...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement