Solved

CANNOT get active document from a dialog box

Posted on 1997-04-16
5
264 Views
Last Modified: 2013-11-20
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
Comment
Question by:chma4
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
serge010697 earned 50 total points
Comment Utility
Try the following code:
((CFrameWnd*)AfxGetMainWnd())->GetActiveDocument()
0
 

Author Comment

by:chma4
Comment Utility
Sorry, still get the NULL pointer... any more suggestion?
0
 
LVL 1

Expert Comment

by:serge010697
Comment Utility
Sorry, that was my fault, this one should work:

((CFrameWnd*)AfxGetMainWnd())->GetActiveFrame()->GetActiveDocument();
0
 
LVL 1

Expert Comment

by:serge010697
Comment Utility
Sorry, that was my fault, this one should work:

((CFrameWnd*)AfxGetMainWnd())->GetActiveFrame()->GetActiveDocument();
0
 

Author Comment

by:chma4
Comment Utility
serge, Tons of Thanks !!!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now