Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi in an MDI application, when user switches between views something have to be updated. what's the best message to handle for realizing when this happens?
in my application a document has only one view, but logically i want to get notified when switch is between documents.
thx
Posted

1 solution

When a window becomes active or inactive, a WM_NCACTIVATE message is send to update the title bar. With view windows, the message is send to the parent frame window of the view (a CMDIChildWnd derived class).

So you may add such handlers to your child frame classes. From the handler, you may use the CFrameWnd member functions GetActiveDocument() and GetActiveView() to pass information to your document and related view.
 
Share this answer
 
Comments
ilostmyid2 12-Apr-12 11:02am    
thank u :)
i added ON_WM_MDIACTIVATE to the child frame's message map and added the handler CChildFrame::OnMDIActivate. is it ok?
ilostmyid2 12-Apr-12 11:27am    
this is also a problem! see the following:
t22 activated, t21 deactivated, in CChildFrame::OnMDIActivate
t21 activated, t22 deactivated, in CChildFrame::OnMDIActivate
t22 activated, t21 deactivated, in CChildFrame::OnMDIActivate
t22::OnDraw
t21::OnDraw
this is the result of two traces, one in CChildFrame::OnMDIActivate and one in Ct2View::OnDraw. this is the result of a File/New command. it indicates that when i add a new document, it gets first activated, then deactivated, then activated again, then drawn and then the deactivated view is also drawn! when the MDI application is of kind tabbed views, how this behavior is justifiable?
so my questions are:
1. after activating the new document, why it gets deactivated and activated again?!
2. a view which is completely hidden must not be drawn.
Jochen Arndt 12-Apr-12 12:01pm    
It's not always traceable why and when messages are send by the Windows framework. I assume that the frames must be activated upon creation of new views. I suggest to ignore all messages for new views (while CView::OnInitalUpdate hasn't been called and finished) and the deactivation messages.
Jochen Arndt 12-Apr-12 12:07pm    
It is not always traceable why and when messages are send by the framework. I assume that the frame must be activated upon creation and initial drawing. I suggest to ignore all messages while the frame/view is created (until CView::OnInitialUpdate has been called) and all deactivation messages.
Jochen Arndt 12-Apr-12 12:07pm    
It is not always traceable why and when messages are send by the framework. I assume that the frame must be activated upon creation and initial drawing. I suggest to ignore all messages while the frame/view is created (until CView::OnInitialUpdate has called) and all deactivation messages.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900