MFC Doc/View: How to obtain a pointer to various objects?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: MFC Doc/View: How to obtain a pointer to various objects?

  1. #1
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    MFC Doc/View: How to obtain a pointer to various objects?

    From this class:You can access this class using:
    CWinAppCMainFrameCChildFrameCDocumentCView
    CWinApp AfxGetMainWnd() or
    m_pMainWnd
    AfxGetMainWnd()->MDIGetActive()AfxGetMainWnd()->GetActiveView()->GetDocument()AfxGetMainWnd()->GetActiveView()
    CMainFrameAfxGetApp() or
    theApp
     MDIGetActive() or
    GetActiveFrame()
    SDI: GetActiveView()->GetDocument()
    MDI: MDIGetActive()->GetActiveView()->GetDocument()
    SDI: GetActiveView()
    MDI: MDIGetActive()->GetActiveView()
    CChildFrameAfxGetApp() or
    theApp
    GetParentFrame() GetActiveView()->GetDocument()GetActiveView()
    CDocumentAfxGetApp() or
    theApp
    AfxGetMainWnd()AfxGetMainWnd()->MDIGetActive() POSITION pos =GetFirstViewPosition();
    GetNextView(pos);

    (see note below)
    CViewAfxGetApp() or
    theApp
    AfxGetMainWnd()GetParentFrame()GetDocument() 
    any other classAfxGetApp()AfxGetMainWnd()AfxGetMainWnd()->MDIGetActive() or
    AfxGetMainWnd()->GetActiveFrame()
    SDI: AfxGetMainWnd()->GetActiveView()->GetDocument()
    MDI: AfxGetMainWnd()->MDIGetActive()->GetActiveView()->GetDocument()
    SDI: AfxGetMainWnd()->GetActiveView()
    MDI: AfxGetMainWnd()->MDIGetActive()->GetActiveView()
    Note: To access only the current view, the document class can call AfxGetMainWnd()->GetActiveView() from a SDI application or AfxGetMainWnd()->MDIGetActive()->GetActiveView() from a MDI application.


    Last edited by Andreas Masur; July 24th, 2005 at 04:33 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center