Solved

Dialogue destruction and member variable existence

Posted on 2004-04-02
5
209 Views
Last Modified: 2013-11-20
Hello !

Quick question about calling DoModal() and the availability of dialogue member variables:

If I say

MyDialogue dlg

if (dlg.DoModal == IDOK) {
   CString s = dlg.m_str;
   int i = dlg.m_i;
   // etc etc etc.. other access of dlg member variables
}
// *

Now, when is the destructor for dlg called, hence up to what point can I access *true* (i.e. not garbage) values like dlg.m_str ?  I put a TRACE statement in my destructor for the dialog class, but it never got displayed !  Also I could still access dlg member variables at the point marked *; well after when I initially figured the dialogue would have been destroyed !

TIA !
0
Comment
Question by:mrwad99
[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
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
Dexstar earned 75 total points
ID: 10743227
@mrwad99:

> Now, when is the destructor for dlg called, hence up to what point can I access
> *true* (i.e. not garbage) values like dlg.m_str ?

The destructor gets called when the object falls out of scope.  If MyDialogue is a local variable in a function, you should be able to access those values throughout the entire function.  Do not get confused about the object that represents the dialog, and the dialog on the screen.  The dialog on the screen gets destroyed before DoModal() returns.  The object that represents it doesn't get destroyed until it falls out of scope.

Hope That Helps,
Dex*
0
 
LVL 19

Author Comment

by:mrwad99
ID: 10743293
Four minutes; you are getting better...

:)
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 10743339
@mrwad99:

> Four minutes; you are getting better...

Heh.  Thanks!  :)

Dex*
0
 
LVL 19

Author Comment

by:mrwad99
ID: 10746949
Dex*,

some time after I closed this question last night (GMT) I realised that nothing I had said actually even insinuated "thanks for answering my question".  So here it is:

Thanks !

PS Thanks also for the link on your profile to di.fm; I had a listen and they certainly are phat beats !

:)
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 10748303
@mrwad99:

You're welcome and you're welcome.  :)

Which stream did you like the best?  I usually listen to Trance or Vocal Trance, but I keep them all in the rotation.  Whatever my mood calls for.  :)

Dex*
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 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