-
June 5th, 2009, 05:23 AM
#1
MFC: CSplitterWnd, runtime class
Hello,
I have the following problem/question:
Let's say I have a class CMyView derived from CView whose constructor can take parameters which influence the view's initial appearance (e.g. an RGB value to set the background color).
Now I want to use CSplitterWnd and create TWO views with CMyView as the runtime class. The two views are supposed to be initialized with different parameters though and therefore have a different initial appearance.
Since I can only pass the runtime class to CSplitterWnd::CreateView how is it possible to influence the construction of the view used with CSplitterWnd?
Thanks in advance!
-
June 5th, 2009, 06:03 AM
#2
Re: MFC: CSplitterWnd, runtime class
Originally Posted by maglite
Hello,
I have the following problem/question:
Let's say I have a class CMyView derived from CView whose constructor can take parameters which influence the view's initial appearance (e.g. an RGB value to set the background color).
Now I want to use CSplitterWnd and create TWO views with CMyView as the runtime class. The two views are supposed to be initialized with different parameters though and therefore have a different initial appearance.
Since I can only pass the runtime class to CSplitterWnd::CreateView how is it possible to influence the construction of the view used with CSplitterWnd?
Thanks in advance!
You will have a view for the program that will own the splitter:
CSplitterWnd m_wndSplitter;
In the OnCreate for your program's main view, you will initialize the splitter and set up two panes:
m_wndSplitter.CreateStatic(this,1, 2); //Creates two side by side panes
Then you create each pane and do an instance of CMyView in each:
Code:
pContext = (CCreateContext*)lpCreateStruct->lpCreateParams;
lpCreateStruct->style |= WS_OVERLAPPED;
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMyView), CSize(0,0), pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMyView), CSize(0,0), pContext);
m_pView0=(CMyView *)m_wndSplitter.GetPane(0,0);
m_pView1=(CMyView *)m_wndSplitter.GetPane(0,1);
You now have two instances of CMyView that are independent of one another that are children of your program's main view.
Bill
-
June 5th, 2009, 06:10 AM
#3
Re: MFC: CSplitterWnd, runtime class
I now see that my question doesn't make much sense in the way that i want to pass parameters to the constructor of the view, since the constructor is of course protected...
Thank you for your answer, wdolson! This is exactly what i needed to know.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|