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

    http://www.programbbs.com/doc/3174.htm

        

     

    获得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下是若干个ChildFrame,ChildFrame中若干个View和Document(可能不成对),ChildFrame管理着View,View和Document进行互操作。
    因此整体框架就出来了,一般除了直接应用的关系都可以通过MainFrame-->Active ChildFrame-->Active View-->Document这条线进行访问,这应该叫什么来自?万能方法吧^_^。
    恕我懒惰,不愿意画一个更详细的图解,凑合着看看吧。
  • 相关阅读:
    Hibernate缓存之初探
    Oracle、MySql、SQLServer 数据分页查询
    LISTAGG WITHIN GROUP函数使用方法
    exp/imp密码特殊字符处理
    Oracle动态授权用户权限
    Centos7二进制安装Mysql8.0.14
    Zabbix监控Windows网卡流量
    Zabbix监控通过jvm插件监控Tomcat
    Linux安装RabbitMQ3.73开启插件shovel并做配置
    yum安装指定路径和配置文件出错
  • 原文地址:https://www.cnblogs.com/carl2380/p/1995009.html
Copyright © 2011-2022 走看看