Solved

Dialogue destruction and member variable existence

Posted on 2004-04-02
5
196 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now