zoukankan      html  css  js  c++  java
  • VC MFC SDI/MDI框架各部分指针获取方式

     

    获得CWinApp

    获得CMainFrame

    获得CChildFrame

    获得CDocument

    获得CView

    CWinApp

     

    AfxGetMainWnd()

    m_pMainWnd

    AfxGetMainWnd()->MDIGetActive()

    AfxGetMainWnd()->GetActiveFrame()

    SDI:AfxGetMainWnd()->GetActiveView()->GetDocument()

    MDI:AfxGetMainWnd()->MDIGetActive()->GetActiveView()->GetDocument()

    SDI:AfxGetMainWnd()->GetActiveView()  
    MDI:AfxGetMainWnd()->MDIGetActive()->GetActiveView()

    CMainFrame

    AfxGetApp()

    theApp

     

    MDIGetActive()

    GetActiveFrame()

    SDI:GetActiveView()->GetDocument()  
    MDI:MDIGetActive()->GetActiveView()->GetDocument()  

    SDI:GetActiveView()  
    MDI:MDIGetActive()->GetActiveView()

    CChildFrame

    AfxGetApp()

    theApp

    GetParentFrame()

     

    GetActiveView()->GetDocument()  

    GetActiveView()

    CDocument

    AfxGetApp()

    theApp

    AfxGetMainWnd()  

    AfxGetMainWnd()->MDIGetActive()

    AfxGetMainWnd()->GetActiveFrame()

     

    POSITION   pos   =   GetFirstViewPosition();GetNextView(pos)  

    CView

    AfxGetApp()

    theApp

    AfxGetMainWnd()  

    GetParentFrame()  

    GetDocument()

     

    在其他类中

    AfxGetApp()

    AfxGetMainWnd()  

    AfxGetMainWnd()->MDIGetActive()

    AfxGetMainWnd()->GetActiveFrame()

    SDI:AfxGetMainWnd()->GetActiveView()->GetDocument()

    MDI:AfxGetMainWnd()->MDIGetActive()->GetActiveView()->GetDocument()

    SDI:AfxGetMainWnd()->GetActiveView()  
    MDI:AfxGetMainWnd()->MDIGetActive()->GetActiveView()

    理一理MFC的这几个类的关系,可以很容易明白上面的这些乱七八糟的逻辑。

    App是应用域,所有的域中的东西都可以通过全局函数访问到它。

    MainFrame是主框架,也基本可以用全局函数访问到。

    MainFrame下是若干个ChildFrameChildFrame中若干个ViewDocument(可能不成对),ChildFrame管理着ViewViewDocument进行互操作。

    因此整体框架就出来了,一般除了直接应用的关系都可以通过MainFrame-->Active ChildFrame

  • 相关阅读:
    文件的上传&预览&下载学习(五)
    文件的上传&预览&下载学习(四)
    MySQL学习(一)大纲
    MySQL学习(四)锁机制
    MySQL学习(五)事务
    小程序在WXML页面添加的data属性,在点击事件中,获取的属性名皆为小写字母
    CSS解决数字,字母自动换行的问题添加wordbreak:breakall; wordwrap:breakword;
    理解CSS盒模型
    浮动
    对于第四章“流程控制”的学习和认识
  • 原文地址:https://www.cnblogs.com/johnpher/p/2570707.html
Copyright © 2011-2022 走看看