|
Overload the CFrameWnd :: Create virtual function, and handle it by yourself. The following is the source code of MFC. I have not changed it. I believe you will handle it yourself.
BOOL CFrameWnd :: Create (LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT&rect,
CWnd * pParentWnd,
LPCTSTR lpszMenuName,
DWORD dwExStyle,
CCreateContext * pContext)
{
HMENU hMenu = NULL;
if (lpszMenuName! = NULL)
{
// load in a menu that will get destroyed when window gets destroyed
HINSTANCE hInst = AfxFindResourceHandle (lpszMenuName, RT_MENU);
if ((hMenu = :: LoadMenu (hInst, lpszMenuName)) == NULL)
{
TRACE (traceAppMsg, 0, "Warning: failed to load menu for CFrameWnd.\n");
PostNcDestroy (); // perhaps delete the C ++ object
return FALSE;
}
}
m_strTitle = lpszWindowName; // save title for later
if (! CreateEx (dwExStyle, lpszClassName, lpszWindowName, dwStyle,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
pParentWnd-> GetSafeHwnd (), hMenu, (LPVOID) pContext))
{
TRACE (traceAppMsg, 0, "Warning: failed to create CFrameWnd.\n");
if (hMenu! = NULL)
DestroyMenu (hMenu);
return FALSE;
}
return TRUE;
} |
|