Why don't splitters appear?
-
I am initialising GUI components (in a CMDIFrameWnd) using the code below. It works fine, except that the CMDIChildWnd child frames are blank at startup. If the user fiddles with the child windows (e.g. stretches them) then the splitter displays immediately appear. What have I missed in the initialisation ? :confused: CMainFrame* pMainFrame = new CMainFrame; if (! pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; CCreateContext context; context.m_pCurrentDoc = NULL; context.m_pCurrentFrame = NULL; context.m_pLastView = NULL; context.m_pNewDocTemplate = NULL; context.m_pNewViewClass = NULL; CMDIChildWnd* alertWnd = new CMDIChildWnd; alertWnd->Create(NULL, "Alerts", WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, CFrameWnd::rectDefault, pMainFrame); CSplitterWnd* alertSplitter = new CSplitterWnd; alertSplitter->CreateStatic(alertWnd, 1, 2, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST); alertSplitter->CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), &context); alertSplitter->CreateView(0, 1, RUNTIME_CLASS(CSsfconView), CSize(100, 100), &context); pMainWnd->ShowWindow(SW_SHOW); pMainWnd->UpdateWindow(); cheers, Neil
-
I am initialising GUI components (in a CMDIFrameWnd) using the code below. It works fine, except that the CMDIChildWnd child frames are blank at startup. If the user fiddles with the child windows (e.g. stretches them) then the splitter displays immediately appear. What have I missed in the initialisation ? :confused: CMainFrame* pMainFrame = new CMainFrame; if (! pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; CCreateContext context; context.m_pCurrentDoc = NULL; context.m_pCurrentFrame = NULL; context.m_pLastView = NULL; context.m_pNewDocTemplate = NULL; context.m_pNewViewClass = NULL; CMDIChildWnd* alertWnd = new CMDIChildWnd; alertWnd->Create(NULL, "Alerts", WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, CFrameWnd::rectDefault, pMainFrame); CSplitterWnd* alertSplitter = new CSplitterWnd; alertSplitter->CreateStatic(alertWnd, 1, 2, WS_CHILD | WS_VISIBLE, AFX_IDW_PANE_FIRST); alertSplitter->CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), &context); alertSplitter->CreateView(0, 1, RUNTIME_CLASS(CSsfconView), CSize(100, 100), &context); pMainWnd->ShowWindow(SW_SHOW); pMainWnd->UpdateWindow(); cheers, Neil
What happens if you pass NULL instead of &context to alertSplitter->CreateView()? Also, this call shouldn't be necessary - pMainWnd->UpdateWindow(); Maybe try without it. CSplitterWnd* alertSplitter should maybe be a member variable of the MDIChild class (or somewhere) so it can be deleted, otherwise a memory leak.