We can use GetDocument to return a pointer to the CDocument associated with the view(eg CFormView).
However if i have created a dialog box (CDialog class), how do i get a pointer to the CDocument???
Printable View
We can use GetDocument to return a pointer to the CDocument associated with the view(eg CFormView).
However if i have created a dialog box (CDialog class), how do i get a pointer to the CDocument???
I think you would have to pass a pointer to the parent to the dialog box...e.g. either the View or the Document class pointer.
Using this you can get to the other classes.
OK... ..
Is there any sample code you can show me??
PHP Code://
// In your view (or document, or frame, etc.)
//
CMyView::OnDialogBox()
{
CMyDialog dlg(GetDocument());
dlg.DoModal();
}
//
// In your dialog box header file:
//
class CMyDocument;
class CDialog : public CDialog
{
// Modify the normal constructor
CMyDialog(CMyDocument *pDoc, CWnd *pParent=NULL);
// Don't allow default constructor
CMyDialog(){ ASSERT(FALSE); }
protected:
CMyDocument *m_pDoc;
}
//
// In your dialog box cpp file
//
CMyDialog::CMyDialog(CMyDocument *pDoc, CWnd *pParent/*=NULL*/)
:: CDialog(CMyDialog::IDD,pParent), m_pDoc(pDoc)
{
}
Is the dialog box you are creating modeless or modal ?
The dialog box i am creating is modal
The code snippet from "0xC0000005" is ideally what you should do.
Nice job 0xC0000005 ;)