CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Apr 2003
    Posts
    100

    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

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    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

  3. #3
    Join Date
    Apr 2003
    Posts
    100

    Re: Access from CDocument to CMDIChildWnd

    Quote Originally Posted by VictorN View Post
    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

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    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

  5. #5
    Join Date
    Apr 2003
    Posts
    100

    Re: Access from CDocument to CMDIChildWnd

    Quote Originally Posted by VictorN View Post
    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

  6. #6
    Join Date
    Apr 2003
    Posts
    100

    Re: Access from CDocument to CMDIChildWnd

    Quote Originally Posted by VictorN View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured