Hi! I have an SDI app and have views in panes. They work whether you open or close the views, etc. I stole this trick from Oleg. Below is a function to place in your mainfrm.cpp that creates a panel window based on a particular view. The view is then created and attached to your document. It will receive all your doc update messages and whatnot:
FrameWnd* CMainFrame::CreateView(CRuntimeClass *type) { CFrameWnd *pFrame = new CFrameWnd; CCreateContext context; ::ZeroMemory(&context, sizeof(context));
context.m_pNewViewClass = type; context.m_pCurrentDoc = NULL; context.m_pCurrentFrame = GetParentFrame();
CDocManager *pManager = AfxGetApp()->m_pDocManager; if (pManager != NULL) { POSITION posTemplate = pManager->GetFirstDocTemplatePosition(); if (posTemplate != NULL) { CDocTemplate *pTemplate = pManager->GetNextDocTemplate(posTemplate); POSITION posDoc = pTemplate->GetFirstDocPosition(); if (posDoc != NULL) { CccAnalyzeDoc *mydoc = (CccAnalyzeDoc *)pTemplate->GetNextDoc(posDoc); context.m_pCurrentDoc = mydoc; if (m_doc == NULL) m_doc = mydoc; } } }
pFrame->Create(NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CRect(0, 0, 0, 0), this, NULL, 0, &context); pFrame->ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED); pFrame->GetWindow(GW_CHILD)->ModifyStyleEx(WS_EX_CLIEN TEDGE, 0, SWP_FRAMECHANGED);
return pFrame; }
Then, to create a view in your "onDockingPaneNotify" routine, just do:
switch (pPane->GetID()) {
...
case IDR_PANE_MYPANE: pPane->Attach(CreateView(RUNTIME_CLASS(myViewClass))); break;
...
}
|