Multiple dialog templates in a Form View
tcatchick@aesprodata.com.au Wednesday, December 18, 1996 Environment: VC++ 1.52, Win3.1, Win95. Peoples, I am creating an application, which has a splitter window. One side uses a tree class display (ie like Windows program manager) and on the other side being blank. When the operator double clicks on one of the tree's leaves I would like to display in the blank form area the dialog associated with this leaf. Is there a way I can provide this heterogeneous behaviour to a FormView class??? Thanks In advance. Theron.C.
Michael -- Michael.Dunphy@HBC.honeywell.com Thursday, December 19, 1996 Subject: Multiple dialog templates in a Form View Environment: VC++ 1.52, Win3.1, Win95. See Knowledgebase Article Q102827 ("Replacing a View in a Splitter Window") - Michael Dunphy Peoples, I am creating an application, which has a splitter window. One side uses a tree class display (ie like Windows program manager) and on the other side being blank. When the operator double clicks on one of the tree's leaves I would like to display in the blank form area the dialog associated with this leaf. Is there a way I can provide this heterogeneous behaviour to a FormView class??? Thanks In advance. Theron.C.
Peter -- cpudude@mem.net Friday, December 20, 1996 [Mini-digest: 2 responses] tcatchick@aesprodata.com.au wrote: > > Environment: VC++ 1.52, Win3.1, Win95. > > Peoples, > > I am creating an application, which has a splitter window. One side > uses a tree class display (ie like Windows program manager) and on the > other side being blank. > > When the operator double clicks on one of the tree's leaves I would > like to display in the blank form area the dialog associated with this > leaf. > > Is there a way I can provide this heterogeneous behaviour to a > FormView class??? > > Thanks In advance. > > Theron.C. I have written a sub-set of the CTreeCtrl that does just about what you are looking for, however, I have not implemented it as a true splitter window, but simply as a "list-box" on the left side of the window and then I load views into the right side of the window. If you'd like to see it, email me and I'll send it to you!! NB: I said it is a subset and I haven't fully tested/debugged it, but if you still want it we could share the testing efforts!! Peter R. Vermilye cpudude@mem.net PS: Who does Microsoft call for help? -----From: Jacques de BroinTo change the View displayed by a splitter window, I made a function called ShowFormView by copying the code in CSplitterWnd::DeleteView CSplitterWnd::CreateView from WinSplit.cpp. When I want to change the view, I simply call this with the CRuntimeClass of the new view. void CMainFrame::ShowFormView(CRuntimeClass* pViewClass) { int row = 1; int col = 0; SIZE sizeInit = CSize(100,100); CCreateContext* pContext = NULL; CWnd* pPane = m_wndSplitterForm.GetPane(row, col); ASSERT_KINDOF(CView, pPane); BOOL bWasActivePane = FALSE; if (m_wndSplitterForm.GetActivePane() == pPane) { bWasActivePane = TRUE; } // default implementation assumes view will auto delete in PostNcDestroy pPane->DestroyWindow(); CCreateContext contextT; if(pContext == NULL) { // if no context specified, generate one from the currently selected // client if possible CView* pOldView = (CView*)m_wndSplitterForm.GetActivePane(); if (pOldView != NULL && pOldView->IsKindOf(RUNTIME_CLASS(CView))) { // set info about last pane ASSERT(contextT.m_pCurrentFrame == NULL); contextT.m_pLastView = pOldView; contextT.m_pCurrentDoc = pOldView->GetDocument(); if (contextT.m_pCurrentDoc != NULL) contextT.m_pNewDocTemplate = contextT.m_pCurrentDoc->GetDocTemplate(); } pContext = &contextT; } CView* pFormView; TRY { pFormView = (CView*)pViewClass->CreateObject(); if (pFormView == NULL) AfxThrowMemoryException(); } CATCH_ALL(e) { TRACE0("Out of memory creating a splitter pane.\n"); // Note: DELETE_EXCEPTION(e) not required return; } END_CATCH_ALL ASSERT_KINDOF(CView, pFormView); ASSERT(pFormView->m_hWnd == NULL); // not yet created DWORD dwStyle = AFX_WS_DEFAULT_VIEW; // TODO: Test on Win95 DWORD dwVersion = ::GetVersion(); BOOL bWin4 = (BYTE)dwVersion >= 4; if (bWin4) dwStyle &= ~WS_BORDER; // Create with the right size (wrong position) CRect rect(CPoint(0,0), sizeInit); if (!pFormView->Create(NULL, NULL, dwStyle, rect, &m_wndSplitterForm, m_wndSplitterForm.IdFromRowCol(row, col), pContext)) { TRACE0("Warning: couldn't create client pane for splitter.\n"); // pFormView will be cleaned up by PostNcDestroy // return FALSE; } // ASSERT((int)_AfxGetDlgCtrlID(pFormView->m_hWnd) == m_wndSplitter.IdFromRowCol(row, col)); pFormView->OnInitialUpdate(); m_wndSplitterForm.RecalcLayout(); // m_wndSplitterForm.SetRedraw(TRUE); // m_wndSplitterForm.RedrawWindow(); if(bWasActivePane) SetActiveView(pFormView); }
| Вернуться в корень Архива |