Hiword, Lowword......please Help!!!!!!

This is a discussion on Hiword, Lowword......please Help!!!!!! within the Windows Programming forums, part of the Platform Specific Boards category; What does this mean? int x=LOWORD(lparam); //x is contained in the lower 16 bits int y=HIWORD(lparam);//y is contained in the ...

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    Hiword, Lowword......please Help!!!!!!

    What does this mean?

    int x=LOWORD(lparam); //x is contained in the lower 16 bits
    int y=HIWORD(lparam);//y is contained in the upper 16 bits


    Ok what does LOWORD and HIGHWORD mean? I mean I know it retreives x and y but I don't really know the meaning of LOWORD and HIGHWORD.....please explain......

  2. #2
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    Picture a 32 bit binary number, for example

    Code:
    1011010010100101  0100101001010010
         High word       Low word
    Clear??
    Visit entropysink.com - It's what your PC is made for!

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    88
    if it in the WM_MOUSEMOVE

    it means
    that int x is the x of the mouse pointer
    an int y is the y of the muse pointer

  4. #4
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    But what would the difference be when doing this?


    int x=LOWORD(lparam); //x is contained in the lower 16 bits
    int y=HIWORD(lparam);//y is contained in the upper 16 bits



    or would it work if I were to invert them like so

    int x=HIWORD(lparam); //x is contained in the lower 16 bits
    int y=LOWORD(lparam);//y is contained in the upper 16 bits

  5. #5
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Originally posted by RobR
    Picture a 32 bit binary number, for example

    Code:
    1011010010100101  0100101001010010
         High word       Low word
    Clear??
    How would that make a different which you would call it from either High word or Low word?
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    OK......look at it like so....

    lParam is a 32bit value......just like an int.......

    Now remember that a byte is a collection of 8 binary bits.....each of which can represent a '1' or a '0'......

    So a 32bit value can represent 4 bytes (32bit / 8 bits per bytes) or 4 collections of 8bits.....like so

    10110100 01111010 11111000 00001101

    Notice how each is 8 bits long.....

    Now with the whole LOWORD/HIWORD.....you are only looking at either the first 16bits (2 bytes) or the last 16bits....so 2 16bit values can be stores in 1 32bit value.....

  7. #7
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Originally posted by Fordy
    OK......look at it like so....

    lParam is a 32bit value......just like an int.......

    Now remember that a byte is a collection of 8 binary bits.....each of which can represent a '1' or a '0'......

    So a 32bit value can represent 4 bytes (32bit / 8 bits per bytes) or 4 collections of 8bits.....like so

    10110100 01111010 11111000 00001101

    Notice how each is 8 bits long.....

    Now with the whole LOWORD/HIWORD.....you are only looking at either the first 16bits (2 bytes) or the last 16bits....so 2 16bit values can be stores in 1 32bit value.....

    Ok, I am not sure I follow you though we split the values of X and Y into 32 bits or something? Let's say X int the first 16 bits and the y in the second 16 bits? If I am wrong please clarify, if I am right however (doubtful) could you use HIWORD for Y and LOWORD for X.?
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by elchulo2002



    Ok, I am not sure I follow you though we split the values of X and Y into 32 bits or something? Let's say X int the first 16 bits and the y in the second 16 bits? If I am wrong please clarify, if I am right however (doubtful) could you use HIWORD for Y and LOWORD for X.?
    Yeah.....the value is 32bit....so that can be seperated into 2 16bit values (x & y)......

    These actual 16bit values are WORDs..... you are assigning them to ints..but as ints are bigger than WORDs....you are ok

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HIWORD and LOWORD macros
    By kalevi in forum C Programming
    Replies: 8
    Last Post: 12-07-2008, 04:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21