参考:
- wine.14
-
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmessage
函数作用:从调用此函数的消息队列中获取消息。
BOOL WINAPI NtUserGetMessage(MSG *msg, HWND hwnd, UINT first, UINT last)
{
HANDLE server_queue = get_server_queue_handle();
unsigned int mask = QS_POSTMESSAGE | QS_SENDMESSAGE;
int ret;
user_check_not_lock();
check_for_driver_events(0);
if(first || last)
{
if((fist <= WM_KEYLST) && (last >=WM_KEYFIRST)) mask |= QS_KEY;
if(((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) || ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST))) mask |= QS_MOUSE;
if((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER;
if((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER;
if((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT;
}
else mask = QS_ALLINPUT;
while(!(ret = peek_message(msg,hwnd, first, last, PM_REMOVE | (mask << 16), mask)))
{
wait_objects(1, &server_queue, INFINITE, mask & (QS_SENDMESSAGE | QS_SMRESULT), mask, 0);
}
if(ret < 0) return -1;
check_for_driver_events(msg->message);
return msg->message != WM_QUIT;
}
根据first与last 划定的范围设置不同的mask值,mask 值即表示需要在消息队列中获取什么消息。实际的查找是由函数peek_message 完成,当peek_message 返回0时,表示没有符合条件的消息,那么就需要调用函数wait_object来等待队列中出现满足条件的消息。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...