• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 597
  • Last Modified:

MFC: Access Violation when accessing parent dialog

Hi,

I'm trying to access the parent dialog from a child dialog using something like this...


double y = ((ParentDialogPointer *)GetParent())->m_l;

Now this code works from one of my child dialog files, but for the other one I get an access violation.

Any ideas why?

Thanks in advance!
0
Ally86
Asked:
Ally86
2 Solutions
 
mrjoltcolaCommented:
Depending on how you create the child dialog, the parent window might not be of type ParentDialogPointer. The parent could be the application, for a modeless dialog. What type of dialogs, and how are you creating?
0
 
alb66Commented:
May be you hadn't set the parent for one dialog
0
 
Ally86Author Commented:
I believe they are Modal Dialogs... Looking at the code for the resource file "MP.rc" the top of the dialog is set as  "DS_MODALFRAME".

I think the parent is the application, the dialogs are created using ...

 create = new NeXus();
   if(create!= NULL)
   {
      BOOL ret = create->Create(IDD_DIALOG4,this);
      if(!ret)   //Create failed.
         AfxMessageBox("NeXus is Currently not Available");
      create->ShowWindow(SW_SHOW);

How would I go about setting the parent ?

Any more info needed I'll be happy to tell!

Thanks
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

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