Solved

Splitter Windows and Menu

Posted on 1998-08-13
7
187 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:cpaalman
  • 4
  • 2
7 Comments
 
LVL 6

Expert Comment

by:snoegler
ID: 1320753
Why don't you process those messages in your CDocument class?
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.
0
 

Author Comment

by:cpaalman
ID: 1320754
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?

0
 
LVL 6

Expert Comment

by:snoegler
ID: 1320755
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.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1320756
Hackomatic answer.

In your CDocument derived class add a pointer member to each view object (or atleast the tree view)

Make a public function in the CDocument class that returns the value of this pointer ( for example: CTreeView * GetTreeView() const )

In the other views you can get hold of this by doing (and call functions too)
GetDocument()->GetTreeView()->SomeFunction() ;

Make sure your override GetDocument() in each view to return a pointer to your document class class, not the CDocument *.  (it's the same pointer just casted).

0
 
LVL 6

Expert Comment

by:snoegler
ID: 1320757
mmmh ... isn't that quite the same as what i wrote ... :)
0
 

Author Comment

by:cpaalman
ID: 1320758
Putting the two suggestions together (from snoegler and answer2000) I think this should work.  Thanks, I'll try it asap.

0
 
LVL 6

Expert Comment

by:snoegler
ID: 1320759
Thank you
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 77
xyBalance chalenge 58 88
ODBC Connection Logging, ADO.NET 6 49
sum28 challenge 31 96
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now