Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

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!!
0
chma4
Asked:
chma4
  • 3
  • 2
1 Solution
 
serge010697Commented:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now