怎样重载PreTranslateMessage
发布网友
发布时间:2022-09-20 23:14
我来回答
共2个回答
热心网友
时间:2023-11-08 04:15
当按下键盘时,首先主程序的CWinApp对象的PreTranslateMessage会被调用。在这条函数中最重要的函数是WalkPreTranslateTree,其实现如下
BOOL PASCAL CWnd::WalkPreTranslateTree(HWND hWndStop, MSG* pMsg)
{
ASSERT(hWndStop == NULL || ::IsWindow(hWndStop));
ASSERT(pMsg != NULL);
// walk from the target window up to the hWndStop window checking
// if any window wants to translate this message
for (HWND hWnd = pMsg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd))
{
CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);
if (pWnd != NULL)
{
// target window is a C++ window
if (pWnd->PreTranslateMessage(pMsg))
return TRUE; // trapped by target window (eg: accelerators)
}
// got to hWndStop window without interest
if (hWnd == hWndStop)
break;
}
return FALSE; // no special processing
}
热心网友
时间:2023-11-08 04:16
如图添加虚函数