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这条线进行访问,这应该叫什么来自?万能方法吧^_^。
    恕我懒惰,不愿意画一个更详细的图解,凑合着看看吧。
  • 相关阅读:
    Chrome cookies folder
    Fat URLs Client Identification
    User Login Client Identification
    Client IP Address Client Identification
    HTTP Headers Client Identification
    The Personal Touch Client Identification 个性化接触 客户识别
    购物车 cookie session
    购物车删除商品,总价变化 innerHTML = ''并没有删除节点,内容仍存在
    453
    购物车-删除单行商品-HTMLTableElement.deleteRow()
  • 原文地址:https://www.cnblogs.com/carl2380/p/1995009.html
Copyright © 2011-2022 走看看