?
Solved

Dialogue destruction and member variable existence

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 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