VC MFC SDI MDI框架各部分指標獲取方式

2021-05-11 13:15:27 字數 1844 閱讀 6993

獲得cmainframe

獲得cchildframe

獲得cdocument

獲得cview

afxgetmainwnd()

m_pmainwnd

afxgetmainwnd()->mdigetactive()

afxgetmainwnd()->getactiveframe()

sdi:afxgetmainwnd()->getactiveview()->getdocument()

mdi:afxgetmainwnd()->mdigetactive()->getactiveview()->getdocument()

sdi:afxgetmainwnd()->getactiveview()  

mdi:afxgetmainwnd()->mdigetactive()->getactiveview()

在cmainframe中

mdigetactive()

getactiveframe()

sdi:getactiveview()->getdocument()  

mdi:mdigetactive()->getactiveview()->getdocument()  

sdi:getactiveview()  

mdi:mdigetactive()->getactiveview()

在cchildframe中getparentframe()

getactiveview()->getdocument()  

getactiveview()

在cdocument中afxgetmainwnd()  

afxgetmainwnd()->mdigetactive()

afxgetmainwnd()->getactiveframe()

position   pos   =   getfirstviewposition();getnextview(pos)  

在cview中afxgetmainwnd()  

getparentframe()  

getdocument()

在其他類中afxgetmainwnd()  

afxgetmainwnd()->mdigetactive()

afxgetmainwnd()->getactiveframe()

sdi:afxgetmainwnd()->getactiveview()->getdocument()

mdi:afxgetmainwnd()->mdigetactive()->getactiveview()->getdocument()

sdi:afxgetmainwnd()->getactiveview()  

mdi:afxgetmainwnd()->mdigetactive()->getactiveview()

理一理mfc的這幾個類的關係,可以很容易明白上面的這些亂七八糟的邏輯。

mainframe是主框架,也基本可以用全域性函式訪問到。

mainframe下是若干個childframe,childframe中若干個view和document(可能不成對),childframe管理著view,view和document進行互操作。

因此整體框架就出來了,一般除了直接應用的關係都可以通過mainframe-->active childframe-->active view-->document這條線進行訪問,這應該叫什麼來自?萬能方法吧^_^。

VC MFC SDI MDI框架各部分指標獲取方式

獲得 獲得cmainframe 獲得cchildframe 獲得cdocument 獲得cview 在中 afxgetmainwnd m pmainwnd afxgetmainwnd mdigetactive afxgetmainwnd getactiveframe sdi afxgetmainwn...

VC MFC SDI MDI框架各部分指標獲取方式

整理總結一下,希望也能幫助一下別人。獲得cmainframe 獲得cchildframe 獲得cdocument 獲得cview afxgetmainwnd m pmainwnd afxgetmainwnd mdigetactive afxgetmainwnd getactiveframe sdi ...

VC MFC SDI MDI框架各部分指標獲取方式

前人在csdn總結的,曾經幫助過我,整理總結一下,希望也能幫助一下別人。獲得cmainframe 獲得cchildframe 獲得cdocument 獲得cview afxgetmainwnd m pmainwnd afxgetmainwnd mdigetactive afxgetmainwnd g...