Click to See Complete Forum and Search --> : Unable to create document view


William Dicks
June 1st, 1999, 03:46 PM
In my app's InitInstance method I set up my app's multiple document template like this:

CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_UMBRELTYPE,
RUNTIME_CLASS( CMyDoc ),
RUNTIME_CLASS( CMyMDIChildWnd ),
RUNTIME_CLASS( CMyView ) );
AddDocTemplate( pDocTemplate );




Later I need to create a new document via CWndApp::OnFileNew. I trace the creation of the child frame through CMyMDIChildWnd's PreCreateWindow 3 times.

BOOL CMyMDIChildWnd::PreCreateWindow(CREATESTRUCT &cs)
{
// Do default processing.
if (!CMDIChildWnd::PreCreateWindow(cs))
return FALSE;

return TRUE;
}




By the third time CMyMDIChildWnd has a handle to its window (m_hWnd). Inside MFC's CMDIChildWnd::Create it returns a NULL when it tries to create this window as shown below. Yet, inside this message loop before SendMessage returns, CMyMDIChildWnd has a valid window handle. It then goes off into assembly code which I cannot follow.

BOOL CMDIChildWnd::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CMDIFrameWnd* pParentWnd,
CCreateContext* pContext)
{
... Removed some stuff
// create the window through the MDICLIENT window
AfxHookWindowCreate(this);
HWND hWnd = (HWND)::SendMessage(pParentWnd->m_hWndMDIClient,
WM_MDICREATE, 0, (LPARAM)&mcs);
... Removed some stuff
}




How can I find this problem? Any suggestions?

William Dicks


***
"Delaying decisions" is too often a euphemism for
"avoiding thinking."
- Bjarne Stroustrup