?
Solved

MFC: Access Violation when accessing parent dialog

Posted on 2009-03-31
3
Medium Priority
?
593 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 189 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 186 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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…
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.
Suggested Courses

649 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