ПамяткаAFX

You might also like

Download as xls, pdf, or txt
Download as xls, pdf, or txt
You are on page 1of 1

MFC Doc/View: How to obtain a pointer to various objects?

From this class: You can access this class using:


CWinApp CWinApp CMainFrame AfxGetMainWnd() CChildFrame AfxGetMainWnd()>MDIGetActive() MDIGetActive() or GetActiveFrame() CDocument AfxGetMainWnd()>GetActiveView()->GetDocument() CView AfxGetMainWnd()->GetActiveView()

CMainFrame AfxGetApp()

or
m_pMainWnd

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

or
theApp

GetParentFrame()

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

CChildFrame

AfxGetApp()

GetActiveView()

or
CDocument theApp AfxGetApp() AfxGetMainWnd()

AfxGetMainWnd()>MDIGetActive() GetParentFrame()

or
CView theApp AfxGetApp() AfxGetMainWnd()

GetDocument()

POSITION pos =GetFirstViewPosition(); GetNextView(pos);

(see note below)


AfxGetMainWnd() AfxGetMainWnd()>MDIGetActive() or AfxGetMainWnd()>GetActiveFrame()

or
any other class theApp AfxGetApp()

SDI: AfxGetMainWnd()-

Note: To access only the current view, the document class can call

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

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

SDI application or AfxGetMainWnd()->MDIGetActive()->GetActiveView() from a

You might also like