HIWORD LOWORD lParam

This is a discussion on HIWORD LOWORD lParam within the Windows Programming forums, part of the Platform Specific Boards category; Is there anyway to write the code fragment below using LOWORD(lParam) and HIWORD(lParam) directly instead of using variables xPos and ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    87

    HIWORD LOWORD lParam

    Is there anyway to write the code fragment below using LOWORD(lParam) and HIWORD(lParam) directly instead of using variables xPos and yPos? For example: if ((int)LOWORD(lParam) <= 8).

    Code:
    xPos = (int)LOWORD(lParam);
    yPos = (int)HIWORD(lParam);
    
    if (xPos <= 8)
    {
        xPos = 0;
    }
    else
    {
        xPos -= 8;
        if (xPos >= rc.right)
        {
            rc.right--;
            xPos = rc.right;
        }
    }
    
    if (yPos <= 2)
    {
        yPos = 0;
    }
    else
    {
        yPos -= 2;
        if (yPos >= rc.bottom)
        {
            rc.bottom--;
            yPos = rc.bottom;
        }
    }

  2. #2
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    You could do that with the conditionals but the compiler will recognize the common expressions and generate code mostly equivalent to what you have already.

    Or do you want to directly modify the LOWORD/HIWORD portion of lParam?
    Last edited by BMJ; 10-09-2010 at 01:51 PM.

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    87
    Thanks for the reply "BMJ". Yes I'm looking for a way to directly modify the LOWORD/HIWORD portion of lParam.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I normally extract the HIWORD / LOWORD,
    use
    and then recreate the LPARAM / WPARAM with MAKELPARAM() or MAKEWPARAM()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

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
  2. destroywindow() problem
    By algi in forum Windows Programming
    Replies: 6
    Last Post: 03-27-2005, 11:40 PM
  3. button in function
    By algi in forum Windows Programming
    Replies: 1
    Last Post: 03-21-2005, 11:12 PM
  4. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM
  5. A Problem with DialogBox()
    By EvBladeRunnervE in forum Windows Programming
    Replies: 5
    Last Post: 02-04-2003, 11:14 PM

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