CANNOT get active document from a dialog box

I want to connect a recordset to a dialog, but I failed to get the active document.  The code is as follows:

BOOL CPlotDialog::OnInitDialog()
{
   CFyp1Doc * pDoc = (CFyp1Doc *)            GetParentFrame()->GetActiveDocument());
   m_pDialogSet = &(pDoc->m_dialogSet);
   m_pDialogSet->Open();
   CDialog::OnInitDialog();
}

/////////////////////////////////////////////

GetParentFrame() is successful, but GetActiveDocument() returns NULL.... so program terminates with error...

Tons of Thanks!!
chma4Asked:
Who is Participating?
 
serge010697Connect With a Mentor Commented:
Try the following code:
((CFrameWnd*)AfxGetMainWnd())->GetActiveDocument()
0
 
chma4Author Commented:
Sorry, still get the NULL pointer... any more suggestion?
0
 
serge010697Commented:
Sorry, that was my fault, this one should work:

((CFrameWnd*)AfxGetMainWnd())->GetActiveFrame()->GetActiveDocument();
0
 
serge010697Commented:
Sorry, that was my fault, this one should work:

((CFrameWnd*)AfxGetMainWnd())->GetActiveFrame()->GetActiveDocument();
0
 
chma4Author Commented:
serge, Tons of Thanks !!!
0
All Courses

From novice to tech pro — start learning today.