Solved

MFC: Access Violation when accessing parent dialog

Posted on 2009-03-31
3
572 Views
Last Modified: 2013-12-14
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
Comment
Question by:Ally86
3 Comments
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 63 total points
ID: 24036140
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
 
LVL 19

Assisted Solution

by:alb66
alb66 earned 62 total points
ID: 24036510
May be you hadn't set the parent for one dialog
0
 

Author Comment

by:Ally86
ID: 24037985
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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: 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. …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

758 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

20 Experts available now in Live!

Get 1:1 Help Now