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这条线进行访问,这应该叫什么来自?万能方法吧^_^。
    恕我懒惰,不愿意画一个更详细的图解,凑合着看看吧。
  • 相关阅读:
    使用C语言生成任意指定长度的一串随机数
    拷贝ssh公钥到 authorized_keys 后仍然无法免密登录的原因记录
    vs2013 远程调试---笔记
    C++ 根据进程名找到对应Pid
    使用C语言判断一个IP 地址是否为私有地址
    WEB后台传数据给前台
    邮箱跳转
    Cookie记住密码
    Linux服务器攻击防御(转)
    APACHE两种域名跳转法简单完成重定向
  • 原文地址:https://www.cnblogs.com/carl2380/p/1995009.html
Copyright © 2011-2022 走看看