第一种方法:
for(;;)
{
GetMessageA(&msg,NULL,0,0);
//printf("%5X,%16X,%16x\n",msg.message,msg.wParam,msg.lParam);
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
这种方法得到的结果少。第二种方法:
LRESULT CALLBACK editproc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
printf("%5X,%16X,%16x\n",msg,wParam,lParam);
return DefWindowProc(hwnd,msg,wParam,lParam);
}
这种方法得到的结果包括第一种方法的全部,还有好多,
比如第一种方法,如果鼠标在窗口上移动,则只能得到连续出现的200号消息。而第二种方法在每两个200号消息之间还有84和20号消息。

解决方案 »

  1.   

    The GetMessage function only retrieves messages associated with the window identified by the hWnd parameter or any of its children
      

  2.   

    各个消息的处理方式是不一样的,有的消息需要发送到消息队列,而有的则是直接调用过程的回调函数
    消息号0x200是WM_MOUSEMOVE
    0x84 是WM_NCHITTEST
    0x20 是WM_SETCURSOR
    当鼠标在窗口移动时,系统首先传递WM_MOUSEMOVE到窗口的消息队列(类似PostMessage效果),并且还发送消息
    WM_NCHITTEST、WM_SETCURSOR到窗口过程,让系统作些“事情”(类似SendMessage效果)。
      

  3.   

    GetMessageA遇到队列消息就返回,遇到非队列消息就调用窗口过程
    DispatchMessageA调用窗口过程
    所以你这里editproc两种消息都可收到