Advertisement

07.02.2008 at 01:27PM PDT, ID: 23535008
[x]
Attachment Details

Exchange information between Dialogs

Asked by Choklander in Windows MFC Programming

Tags: , ,

I have actually two problems.

First is the way VS 2008 is acting. Lets say I have two Dialogs. Dialog1 and Dialog2.
Lets look at their header files. In Dialog1.h I put #include "Dialog2.h". In Dialog2.h I put #include Dialog1.h".
Well it looks fine but if I make a variable of class CDialog2 in Dialog1.h well the program crashes.
If memory servers me right this was possible in Visual Studio 6.0.
I put those dialog headers there because I need to create Dialog2 when you press a button inside Dialog1. And I need to check a variable from Dialog1 in Dialog2 at run time.
I go around this problem by include the header file of Dialog2 in the header file of Dialog1. And the header file of Dialog1 in the cpp file of Dialog2.
Well like that I can create Dialog2 when I press a button in Dialog1. But now comes my other problem.

Lets say I have a variable CDialog1 dlg1. I put this inside PreInitDialog() function in Dialog2. Why I do this? Well because I create my controls in Dialog2 dynamically and if I want to bind them with DDX_Control in the DoDataExchange() I need to create them before that function is called. Now here is the problem at last. If I write if(dlg1.MyVariable == 10) nothing happens even if MyVariable is 10. I made a little formatting and tried to put MyVariable inside a CString to see what is it's value. Well it crashed with a weird error. It sends me to xtoa.c file pointing at the check for buffer overrun.
Can someone tell me how to get information between dialogs? I want to get the value of a public member from Dialog1 and check its value in Dialog2.Start Free Trial
[+][-]07.03.2008 at 01:03AM PDT, ID: 21923515

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Windows MFC Programming
Tags: Microsoft, VS, 2008
Sign Up Now!
Solution Provided By: alb66
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.03.2008 at 01:04AM PDT, ID: 21923520

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628