Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dialogue destruction and member variable existence

Posted on 2004-04-02
5
Medium Priority
?
223 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 300 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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