-
November 25th, 2012, 11:17 PM
#1
Access from CDocument to CMDIChildWnd
Hello,
I'm developing an MDI(MFC) application (with MSDEV 2010) that creates few pairs of doc-view.
From the CDocument object I want to access the CMDIChildWnd object to update the status BAR.
How can I do it ?
Thanks,
Zvika
-
November 26th, 2012, 04:06 AM
#2
Re: Access from CDocument to CMDIChildWnd
The best way (in the most cases) to update a status bar is using ON_UPDATE_COMMAND_UI
mechanism.
To access child frame from (not only!) CDocument derive class you can use this code:
Code:
CMDIChildWnd* pChild = ((CMainFrame*)AfxGetMainWnd())->MDIGetActive();
//or this one
CMDIChildWnd* pChild = ((CMainFrame*)AfxGetApp()->m_pMainWnd)->MDIGetActive();
Victor Nijegorodov
-
November 26th, 2012, 04:56 AM
#3
Re: Access from CDocument to CMDIChildWnd
Originally Posted by VictorN
The best way (in the most cases) to update a status bar is using ON_UPDATE_COMMAND_UI
mechanism.
To access child frame from (not only!) CDocument derive class you can use this code:
Code:
CMDIChildWnd* pChild = ((CMainFrame*)AfxGetMainWnd())->MDIGetActive();
//or this one
CMDIChildWnd* pChild = ((CMainFrame*)AfxGetApp()->m_pMainWnd)->MDIGetActive();
Hello,
MDIGetActive returns only the active frame.
But I have 2 (or more) doc-view pairs all displayed in the same MainFrame.
Each doc runs a thread that has to update its CMDIChildWnd object.
Thanks,
Zvika
-
November 26th, 2012, 05:08 AM
#4
Re: Access from CDocument to CMDIChildWnd
Why do you need to update a (chÃ*ld) frame window?
Every document just holds some data. To diplay this data the View were designed to use. Ro update the views for the current document there is a CDocument::UpdateAllViews method. And the view classes (derived from CView) just use overidden OnUpdate that is called in response to CDocument::UpdateAllViews call.
PLease, read about Doc/View architecture in MSDN.
Victor Nijegorodov
-
November 26th, 2012, 03:38 PM
#5
Re: Access from CDocument to CMDIChildWnd
Originally Posted by VictorN
Why do you need to update a (chÃ*ld) frame window?
Every document just holds some data. To diplay this data the View were designed to use. Ro update the views for the current document there is a CDocument::UpdateAllViews method. And the view classes (derived from CView) just use overidden OnUpdate that is called in response to CDocument::UpdateAllViews call.
PLease, read about Doc/View architecture in MSDN.
Dear
-
November 26th, 2012, 03:40 PM
#6
Re: Access from CDocument to CMDIChildWnd
Originally Posted by VictorN
Why do you need to update a (chÃ*ld) frame window?
Every document just holds some data. To diplay this data the View were designed to use. Ro update the views for the current document there is a CDocument::UpdateAllViews method. And the view classes (derived from CView) just use overidden OnUpdate that is called in response to CDocument::UpdateAllViews call.
PLease, read about Doc/View architecture in MSDN.
Dear Victor,
You help is highly appreciated.
Best regards,
Zvika
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|