• Advertisement

Archived

This topic is now archived and is closed to further replies.

Wanna explain LOWORD, HIWORD, DWORD?

This topic is 6446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Doh! Matt beat me to it. That was the explanation I really needed. I think I needed to know if word and dword were Microsoft terms or part of a generic heirarchy, like you just showed.

Thanks, everyone! All of this, in less than an hour. I love this place.

Share this post


Link to post
Share on other sites
Yeah, just wait til we all get to Win64 programming and then the newbies ask someone to explain what a QWORD (quadword) or an INT64 is

... or even a PARAGRAPH for you ASM junkies.

Edited by - Marsupial Rodentia on June 23, 2000 2:03:26 PM

Share this post


Link to post
Share on other sites
Isn''t a PARAGRAPH 16byte alignment? Must take some more pills now...

When using 16bit environment:
int - 16bits
BYTE - unsigned char
WORD - unsigned (int)
DWORD - long (int)

When using 32bit environment:
int - 32bits
BYTE - unsigned char
WORD - unsigned short (int)
DWORD - unsigned (int)

Share this post


Link to post
Share on other sites
Just one thing:
I think you said HIWORD and LOWORD were used to extract the lParam and wParam. Noooo. lParam and wParam are 2 different variables. You use LOWORD and HIWORD to extract 2 chunks of data from one of them. So lParam could store an x value in HIWORD and a y value in LOWORD. or something.
I''m guessing DWORD stands for double word, cos it''s 2 WORDs you see. WORD isn''t a microsoft term I don''t think.
Anyway, hope I havn''t shattered anyone''s new-found understanding with my mumblings.
Frank

Share this post


Link to post
Share on other sites
A WORD is not Micro$ofts term, its just two bytes, and DWORD is a double WORD, as in 32bits(4 Bytes), as so many of you said

Share this post


Link to post
Share on other sites
Yes, it does sound like rap...

Microsoft does have somewhat strange APIs anyway. Look at GDI!

- DarkMage139
"Real game developers don't change the rules. Real game developers don't break the rules. Real game developers make the rules!"
"Originality (in games) is the spice of life!"

Share this post


Link to post
Share on other sites

  • Advertisement