|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Lynn Reid
|
Jun 22, 2006 - 10:45 PM
|
First, apologies for my simple questions as I am quite new to Prof-UIS. Here’s my basic layout:
A) I have a MDI Doc/View application. The Mainframe has a CExtTabMdiWnd m_wndMdiTabs, which nicely implements showing each open document with a class CPrimaryView. I can click on the tabs and all is well -- I can have, say, 4 open documents displayed in 4 open tabs.
B) I have created a CExtControlBar control bar m_wndBar within my Mainframe in the OnCreate function. I have also derived a class from CFrameWnd, call it CXCFrame. After the m_wndBar is created, I create a CXCFrame and attach it to the control bar ala (plus a bunch of error checking): m_pXCFrame = STATIC_DOWNCAST(CXCFrame, RUNTIME_CLASS(CXCFrame)->CreateObject() ); m_pXCFrame->Create( ::AfxRegisterWndClass(0), _T("FrameTitle"), WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), &m_wndBar, NULL, NULL) )
C) Now WITHIN the frame, I have a splitter window. This splitter window is created in the CXCFrame’s OnCreateClient. I then attach two new views CView1 and CView2 to the splitter window like this: BOOL CXCFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { BOOL bCreateSplitter = m_wndSplitter.CreateStatic(this,2,1) ; if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CView1), CSize(40,40),pContext) || !m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CView2), CSize(0,0),pContext) ) { TRACE0("Couldn’t create views within splitter in XCFrame\n"); return FALSE; }
return bCreateSplitter; }
D) So far, so good. I can draw in the CView1::OnDraw and CView2::OnDraw. But HERE"S MY QUESTION:
Q: How do I attach the current document CDocument to these two views CView1 and CView2 IN ADDITION to CPrimaryView? I want to be able to cycle through all three views with GetNextView(..) for example. And I want CDocument.UpdateAllViews() to affect the views within the control bar splitter window.
Note that I do not have to have, say, 4 open control bars. I only want the currently active document attached to this single control bar/framewnd/splitter.
I suspect I have to do something within the MDIChildWnd::OnMDIActivate, and that something has to do with CDocument->AddView(pCView1)..... Unfortunately, I can’t figure out how to get a pointer to pCView1 within my document! (Kind of a circular problem....) The only thing I can figure out how to get a pointer to is the frame window XCFrame.
Hope this isn’t too confusing; personally I’m a bit lost. Thanks
|
|
Technical Support
|
Jun 23, 2006 - 10:58 AM
|
To attach the view window to the document object, just invoke the CDocument::AddView() method. This is enough to set a valid connection between the document and its view in MFC. To access any window inside the splitter window, you should invoke the following code: CSplitterWnd * pWndSplitter = . . .
int nColNo = . . .
int nRowNo = . . .
int nDlgCtrlID = pWndSplitter->IdFromRowCol( nRowNo, nColNo );
CWnd * pWndInsideTheSplitter = pWndSplitter->GetDlgItem( nDlgCtrlID );
ASSERT_VALID( pWndInsideTheSplitter ); The pWndInsideTheSplitter window is one of your view windows. You can use the STATIC_DOWNCAST() or DYNAMIC_DOWNCAST() macro with the pWndInsideTheSplitter window to access the desired C++ class type.
|
|