|
-
July 19th, 2002, 04:20 AM
#1
Help needed on GetDocument
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???
-
July 19th, 2002, 04:37 AM
#2
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.
-
July 19th, 2002, 04:57 AM
#3
OK... ..
Is there any sample code you can show me??
-
July 19th, 2002, 05:23 AM
#4
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)
{
}
-
July 19th, 2002, 05:25 AM
#5
Is the dialog box you are creating modeless or modal ?
-
July 19th, 2002, 05:27 AM
#6
The dialog box i am creating is modal
-
July 19th, 2002, 06:05 AM
#7
The code snippet from "0xC0000005" is ideally what you should do.
Nice job 0xC0000005
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
|