Two views in splitterwindow, same base class
Hello,
I was woondering how can I use the same class for 2 different views. I have a SDI application with splitter window and I want to use the same class called "CMyFormView" for both the views. Here is a creation code
Code:
.
...
......
........
......
.....
if(!m_wndSplitter2.CreateView(0, 0,RUNTIME_CLASS(CMyFormView), CSize(0, 400), pContext))
return false;
if (!m_wndSplitter2.CreateView(1,0 ,RUNTIME_CLASS(CMyFormView), CSize(0, 0), pContext))
......
In the CFormView class, I have member variable called iSwitch to keep track of which CFormView object I am dealing with. I need to initialize this variable appropriately during the creation of the CFormView objects. However, how can I initialize this variable during the construction of the view object in mainframe class as shown above?
You might say that I should create another class derived from CMyFormView and no more functionality to it. But I want to avoid creating another class if possible. Any suggestions? Thanks
m m
mssange from mainframe to formview??
could you give me a few lines of code to show what kind of messages are you asking about? Thanks. I'll get back to you.
Sincerely
m m
Splitter windows, and which view?...
In terms of which view receives a message, part of the rationale of the Doc/View architecture is that you shouldn't have to worry about that. All a view should need to care about is keeping in sync with its document, handling the messages it receives, and displaying the document in its particular way. The framework determines for you which view in a splitter receives a message.
It seems to me that if your views need to know which pane they're in (and will display differently depending on the answer?), then strictly speaking they're different views. It's a bit of a hack to keep it to one class which works two different ways ... though if your solution works, maybe it's a good hack!
By the way, have you looked at the "Scribble" sample application in the VC++ documentation? It demonstrates using a splitter window with the same CView in each part, and talks about how to do it in SDI apps.