Solved

MFC: Access Violation when accessing parent dialog

Posted on 2009-03-31
3
583 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordappend challenge 8 199
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 103
java. non-English characters encoding problem. intellij idea 3 88
Problem to App source 6 69
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
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.

790 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