-
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;
}
}
-
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?
-
Thanks for the reply "BMJ". Yes I'm looking for a way to directly modify the LOWORD/HIWORD portion of lParam.
-
I normally extract the HIWORD / LOWORD,
use
and then recreate the LPARAM / WPARAM with MAKELPARAM() or MAKEWPARAM()