我在回调函数中AfxGetMainWnd()->PostMessage(WM_CUSTOM1),在我的CView却拦截不到(我用Spy++可以看到post的WM_CUSTOM1),相应的消息映射我已添加(在CView.h ,CView.cpp中):
1)afx_msg Long OnCustm1(UINT,LONG);
2)ON_MESSAGE(WM_CUSTOM1,OnCustm1)
3)LONG OnCustm1(UINT,LONG) {;}
但我写在CMainFrame里,就可以拦截到。不知为何?请赐教
1)afx_msg Long OnCustm1(UINT,LONG);
2)ON_MESSAGE(WM_CUSTOM1,OnCustm1)
3)LONG OnCustm1(UINT,LONG) {;}
但我写在CMainFrame里,就可以拦截到。不知为何?请赐教
{
// Pump through current view FIRST.
CView* pView = GetActiveView();
if (pView != NULL && pView->OnCmdMsg(...))
return TRUE; // Then pump through frame.
if (CWnd::OnCmdMsg(...))
return TRUE; // Last but not least, pump through application.
CWinApp* pApp = AfxGetApp();
if (pApp != NULL && pApp->OnCmdMsg(...))
return TRUE; return FALSE;
}
可以
::PostMessage(视图句柄,WM_CUSTOM1)
并不是你想要发给CView的
所以你收不到
你可以按crybird(寒号鸟)那样说得做做看