Article ID: 190964
Article Last Modified on 11/21/2006
129471 How to SubClass the MDIClient by Using MFC
// CMDIClientWnd is the MDI client window. OnMdiGetActivate() is
// the message handler for WM_MDIGETACTIVE.
BEGIN_MESSAGE_MAP(CMDIClientWnd, CWnd)
//{{AFX_MSG_MAP(CMDIClientWnd)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_MDIGETACTIVE, OnMdiGetActivate)
END_MESSAGE_MAP()
// Validate the HWND returned from processing the WM_MDIGETACTIVE
// in the default window procedure. Returns NULL if an invalid MDI
// child window is found.
afx_msg LRESULT CMDIClientWnd::OnMdiGetActivate(WPARAM, LPARAM)
{
LRESULT rvalue = Default();
if (rvalue)
{
CMDIChildWnd* pWnd =
(CMDIChildWnd*)CWnd::FromHandle((HWND) rvalue);
if (pWnd &&
pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) == 0)
{
return NULL;
}
}
return rvalue;
}
CMDIChildWnd* CMDIFrameWnd::MDIGetActive(BOOL* pbMaximized) const
{
// Check first for MDI client window not created.
if (m_hWndMDIClient == NULL){
if (pbMaximized != NULL)
*pbMaximized = FALSE;
return NULL;
}
// MDI client has been created, get active MDI child.
HWND hWnd = (HWND)::SendMessage(m_hWndMDIClient, WM_MDIGETACTIVE,
0, (LPARAM)pbMaximized);
CMDIChildWnd* pWnd = (CMDIChildWnd*)CWnd::FromHandle(hWnd);
ASSERT(pWnd == NULL || pWnd-
>IsKindOf(RUNTIME_CLASS(CMDIChildWnd)));//>-- ASSERTS HERE
...
}
129471 How to SubClass the MDIClient by Using MFC
Additional query words: Active Document Server kbvc600bug IE IE401 401
Keywords: kbbug kbfix kbnoupdate KB190964