what is correct way to update custom dialogbars in document/view?
-
What is correct way to update custom dialogbars in document/view MDI architecture when the current document is deactivated or a new document is activated. I am currently trying to send messages to the CMainFrame:public CMDIFrameWnd when a CView is selected and sets a different active document. This does not take into account other ways in which the Active document might be set (I don't know hat these might be). CMainFrame can see all the dialog bars and should be the one to update them based on the active document when the active document is changed. I was looking for a simple OnActivateDocument() event, or something like it, in CMainFrame couldn't seem to find it. There has to be a simple way and I am just missing it.
-
What is correct way to update custom dialogbars in document/view MDI architecture when the current document is deactivated or a new document is activated. I am currently trying to send messages to the CMainFrame:public CMDIFrameWnd when a CView is selected and sets a different active document. This does not take into account other ways in which the Active document might be set (I don't know hat these might be). CMainFrame can see all the dialog bars and should be the one to update them based on the active document when the active document is changed. I was looking for a simple OnActivateDocument() event, or something like it, in CMainFrame couldn't seem to find it. There has to be a simple way and I am just missing it.
By design, this is usually done in a CView::OnInitialUpdate() override. If you really must handle window initialization from another window class then you can define your own WM_ messages or add methods to your window classes. At that point you're really not tied to the Doc/View architecture so you may find yourself fighting it. If you handle scrollbar initialization in a CView::OnInitialUpdate() override then your view classes will stay within the doc/view framework. Just call it when you change the view's associated document.
-
What is correct way to update custom dialogbars in document/view MDI architecture when the current document is deactivated or a new document is activated. I am currently trying to send messages to the CMainFrame:public CMDIFrameWnd when a CView is selected and sets a different active document. This does not take into account other ways in which the Active document might be set (I don't know hat these might be). CMainFrame can see all the dialog bars and should be the one to update them based on the active document when the active document is changed. I was looking for a simple OnActivateDocument() event, or something like it, in CMainFrame couldn't seem to find it. There has to be a simple way and I am just missing it.
gor wrote:
CMainFrame can see all the dialog bars and should be the one to update them based on the active document when the active document is changed.
I agree. I update dialog bars from CMainFrame in much the same way as you descibe, except that I make the functions public and call them directly from my view/doc classes instead of sending messages. I override CView::OnActivateView() to get the correct action when the current view is deactivated or a new view is activated. The only problem I had with this was coping with the counter-intuitive way the system sets the pActiveView and pDeactiveView parameters (I'm not sure if this is relevant to your enquiry, but I can provide a code sample if you are interested). I don't know if this is the best approach, but I can vouch for the fact that it works, and that it deals with activation of views by conventional mouse clicks and custom code. It seems strange to me too that there is no function in the CMDIFrameWnd class that can be overridden to achieve this - if you ever discover a better way I would be very interested to hear. Best Regards Cliff