April 23rd, 1999, 11:42 PM
Hi Everybody
I have a splitter window and when the user clicks on one of the tool bar buttons it is supposed to call a function in each of the 2 view's. Could somebody please give me an example of how to make a function in my view class and be able to call it in my MainFrame class.
Thanks
tchung
April 24th, 1999, 01:17 AM
Apply this Problem and solution.
Let's make three Splitter-Windows like this.
---------------------------------
| CLeftPane | |
-----------------| CRightPane |
| | |
| CLeftBotPane | |
| | |
---------------------------------
1) Make three Views-CLeftPane, CLeftBotPane, CRightPane from Base-Class(CView,CFormView, etc) what you want.
2) then, make this member-variable in CMainFrame
CSplitterWnd m_wndChSplitter;
3) Next, write this code in MainFrame::OnCreateClient()
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT, CCreateContext* pContext)
{
m_wndSplitter.CreateStatic(this,1,2);
int nID=m_wndSplitter.IdFromRow(0,0);
m_wndChSplitter.CreateStatic(&m_wndSplitter,2,1,WS_CHILD|WS_VISIBLE,nID);
m_wndChSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftPane),CSize(100,100),pContext);
m_wndChSplitter.CreateView(1,0,RUNTIME_CLASS(CLeftBotPane),CSize(100,100),pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CRightPane),CSize(100,100),pContext);
m_wndSplitter.SetColumnInfo(0,100,0);
return TRUE;
}
4) you'd like to access a View from another View or MainFrame.
example! say " Call OnDraw() in CLeftBotPane class from CRightPane View.
You can do that in this way.
CLeftBotPane *pView=
(CLeftBotPane *)((CSplitterWnd *)GetParent())->GetPane(0,0);
pView->OnDraw();
OR , in this way.
CLeftBotPane *pView=
(CLeftBotPane *)((CSplitterWnd *)GetParent())->GetPane(0,0);
pView->test();
Invalidate(FALSE);
where test() function is a member-function in CLeftBotPane class .
Remember the SplitterWindow is derived from CWnd.
Is that all-right! I hope so!.
by <I><font color=cyan>nfuox</font></I>
April 24th, 1999, 07:45 PM
Thanks tchung!!!
That is exaclty what I was trying to do!!!