Solved

CANNOT get active document from a dialog box

Posted on 1997-04-16
5
270 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
ID: 1301035
Try the following code:
((CFrameWnd*)AfxGetMainWnd())->GetActiveDocument()
0
 

Author Comment

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

Expert Comment

by:serge010697
ID: 1301037
Sorry, that was my fault, this one should work:

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

Expert Comment

by:serge010697
ID: 1301038
Sorry, that was my fault, this one should work:

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

Author Comment

by:chma4
ID: 1301039
serge, Tons of Thanks !!!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
has22 challenge 11 104
lucky13 challenge 11 154
ShiftLeft challenge 21 85
changeXy challenge 13 88
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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