is there a function in dlg class as getdocument()?
I want to get a doc*
in dlg
class, and i know in view class we 开发者_开发问答can get doc*
like
doc* pdc=getdocument();
But how can i do it in dlg
class?
There is no function in CDialog
to retrieve a document pointer. To give your dialog access to the document, you can add a pointer or reference to the document as a member variable of the dialog class, and initialise it in the dialog's constructor.
CMyDocument* doc = GetDocument();
CMyDialog dialog(doc);
dialog.DoModal();
MFC's CDialog class does not have built-in CDocument's. You can implement a CFormView that is derived from CView (which are part of the Document/View architecture of MFC), but CFormView is not a dialog. However, CFormView's can hold controls like a dialog - you can actually assign a dialog template to a CFormView.
you can get document from dialog by doing as follows:
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
CMyProjDoc* pDoc = (CMyProjDoc*)(pFrame->GetActiveDocument());
pDoc->m_item[i].name // use
精彩评论