保捱科技网
您的当前位置:首页用三个函数捕捉消息 先后顺序 判断消息的来源 子窗口的判断

用三个函数捕捉消息 先后顺序 判断消息的来源 子窗口的判断

来源:保捱科技网

APP 的PreTranslateMessage(MSG* pMsg)

APP的ProcessMessageFilter(int code, LPMSG lpMsg)

Dlg的PreTranslateMessage(MSG* pMsg)


消息被捕捉的顺序是 1 APP 的 PreTranslateMessage

2 Dlg 的 PreTranslateMessage

3 APP的 ProcessMessageFilter

==========================================================

在APP的ProcessMessageFilter 里判断消息来源是不是对话框


1 APP 成员变量 HWND m_hwndDlg;

2 在APP 中初始化为 NULL

3 在Dlg中 初始化为 theApp.m_hwndDlg=m_hWnd;

4 在Dlg ONDESTROY中  theApp.m_hwndDlg=NULL;


5APP中对消息进行判断 

if((lpMsg->hwnd==this->m_hwndDlg)||::IsChild(this->m_hwndDlg,lpMsg->hwnd))

//::IsChild 参数2是不是参数1的child

因篇幅问题不能全部显示,请点此查看更多更全内容