class CMainFrame :
public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CChildViewAnimate<CMainFrame>,
public CMessageFilter,
public CIdleHandler
Next, change the main frame's PreTranslateMessage method to this:
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
return TRUE;
return ChildPreTranslateMessage(pMsg);
The call to ChildPreTranslateMessage ensures that the active child view class has a chance to do some custom message translation work. To enable this, you must derive all you child view classes from CChildView, like this:
class CSlideFormView :
public CDialogImpl<CSlideFormView>,
public CChildView<CSlideFormView>
If you need to do custom message translation, you must override the PreTranslateMessage:
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if(!::IsWindow(m_hWnd))
return FALSE;
return CWindow::IsDialogMessage(pMsg);
}
Note the IsWindow test: it is there to avoid having this method called when the child window is already destroyed.
No comments:
Post a Comment