HIWORD是High Word的缩写,作用是取得某个4字节变量(即32位的值)在内存中处于高位的两个字节,即一个word长的数据;
LOWORD是Low Word的缩写,作用是取得某个4字节变量(即32位的值)在内存中处于低位的两个字节,即一个word长的数据;
Win32编程常用;
Win32窗口编程中,收到 WM_SIZE消息时,也就是窗口大小变化时,如下从消息的lParam参数可取出窗口的客户区宽度和长度,
cxClient = LOWORD (lParam) ;
cyClient = HIWORD (lParam) ;
收到 WM_MOUSEMOVE 消息时,如下取出鼠标的x和y坐标;
pt.x=LOWORD (lParam) ;
pt.y=HIWORD (lParam) ;
如果有一个数据0XCCDDEEFF ,如下则取出高位和低位,
high = HIWORD(0XCCDDEEFF) ;
low = LOWORD(0XCCDDEEFF) ;
下面输出相关的值看一下;
/*----------------------------------------2020.10.11, by bo----------------------------------------*/#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;int WINAPI WinMain (HINSTANCE hInstance,