cpaalman
asked on
Splitter Windows and Menu
I have an appication with a custom CMDIChildWnd. The window is split with a TreeView on the left window pane and depending on the type of data selected in the TreeView, the right pane uses the appropriate view class.
On the menu, I have added options, one is to add a selection to the Tree View. If the tree view window is the current window, the menu function works fine. If the View class in the right pane is the window in focus, the menu option is grayed out.
I added code to the View class to handle the menu, but how do I call the function in my Tree view class to actually process the code to add a selection to the tree view.
On the menu, I have added options, one is to add a selection to the Tree View. If the tree view window is the current window, the menu function works fine. If the View class in the right pane is the window in focus, the menu option is grayed out.
I added code to the View class to handle the menu, but how do I call the function in my Tree view class to actually process the code to add a selection to the tree view.
ASKER
That would probably work great, but I need to call specific functions in the View classes. How can I call them from the Document class?
If i got you right, you have the tree-view (i.e. the left pane) always activated.
In the OnInitialUpdate() function of this view class you could store a pointer to this
view in your CDocument object:
GetDocument()->m_TreeView= this;
I am not sure if there exists a 'cleaner' way to do this. I once wrote a FTP Client for
intranet usage with a similar design to yours - left pane 'explorer', right pane the files,
and i did the handling this way. I've searched the MFC doc/view architecture manual for
a 'clean' way, but the documentation has not been helpful in this case.
P.S: Before the user can interact with your application(and thus with the document)
it is ensured that OnInitialUpdate() has been called - so it is safe to use the m_TreeView
pointer.
In the OnInitialUpdate() function of this view class you could store a pointer to this
view in your CDocument object:
GetDocument()->m_TreeView=
I am not sure if there exists a 'cleaner' way to do this. I once wrote a FTP Client for
intranet usage with a similar design to yours - left pane 'explorer', right pane the files,
and i did the handling this way. I've searched the MFC doc/view architecture manual for
a 'clean' way, but the documentation has not been helpful in this case.
P.S: Before the user can interact with your application(and thus with the document)
it is ensured that OnInitialUpdate() has been called - so it is safe to use the m_TreeView
pointer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mmmh ... isn't that quite the same as what i wrote ... :)
ASKER
Putting the two suggestions together (from snoegler and answer2000) I think this should work. Thanks, I'll try it asap.
Thank you
Remember the command-routing: View/Doc/Mainframe ...
If the active view class has no handler for the menu function, it gets grayed. So handling
these in the CDoc class should help.