February 2nd, 2004 04:39 PM
#1
MFC Doc/View: How to obtain a pointer to various objects?
From this class: You can access this class using: CWinApp CMainFrame CChildFrame CDocument CView CWinApp AfxGetMainWnd() orm_pMainWnd AfxGetMainWnd()->MDIGetActive() AfxGetMainWnd()->GetActiveView()->GetDocument() AfxGetMainWnd()->GetActiveView() CMainFrame AfxGetApp() ortheApp MDIGetActive() orGetActiveFrame() SDI: GetActiveView()->GetDocument() MDI: MDIGetActive()->GetActiveView()->GetDocument() SDI: GetActiveView() MDI: MDIGetActive()->GetActiveView() CChildFrame AfxGetApp() ortheApp GetParentFrame() GetActiveView()->GetDocument() GetActiveView() CDocument AfxGetApp() ortheApp AfxGetMainWnd() AfxGetMainWnd()->MDIGetActive() POSITION pos =GetFirstViewPosition(); GetNextView(pos); (see note below)CView AfxGetApp() ortheApp AfxGetMainWnd() GetParentFrame() GetDocument() any other class AfxGetApp() AfxGetMainWnd() AfxGetMainWnd()->MDIGetActive() orAfxGetMainWnd()->GetActiveFrame() SDI: AfxGetMainWnd()->GetActiveView()->GetDocument() MDI: AfxGetMainWnd()->MDIGetActive()->GetActiveView()->GetDocument() SDI: AfxGetMainWnd()->GetActiveView() MDI: AfxGetMainWnd()->MDIGetActive()->GetActiveView() Note: To access only the current view, the document class can call AfxGetMainWnd()->GetActiveView() from a SDI application or AfxGetMainWnd()->MDIGetActive()->GetActiveView() from a MDI application.
Last edited by Andreas Masur; July 24th, 2005 at 03:33 PM .
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks