Re: Closing modeless dialogs
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 11 Mar 2008 12:48:13 -0500
Modeless dialogs are one of the places where you typically have to actually allocate on
the heap. Creating one during InitInstance is a bit dangerous, because the message pump
is not yet working.
As already pointed out, you don't use OnOK to close a modeless dialog; in fact, you have
to override it and remove its body, as you also have to do for OnCancel.
If you get assertions, your program is wrong, and you have to fix it. But note that what
you are showing here is a compiler warning; you have not said what the assertion is, what
file it occurs in, what line it is on, and what version of VS you are using.
joe
On Tue, 11 Mar 2008 16:52:46 +0100, Torsten Hensel
<Hensz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hi!Joseph M. Newcomer [MVP]
I created a simple dialog-based application. Then I created a modeless
dialog in MyApp::InitInstance - the dialog object is created on the
stack. Displaying the dialog works (I call Create() first and then
ShowWindow(SW_SHOW)). But when I close the dialog using either
DestroyWindow() or CDialog::OnOK() I get the following warning (and
assertions):
Warning: calling DestroyWindow in CDialog::~CDialog --
OnDestroy or PostNcDestroy in derived class will not be called.
Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or
PostNcDestroy in derived class will not be called.
Btw. when I use OnOK I get only two assertions, with DestroyWindow I get
three.
I searched for those warnings in google, and I searched for modeless
dialogs in general. The only thing I found was to implement the
PostNcDestroy function with delete this; But this should only be
necessary when creating the dialog object on the heap...
What can I do to prevent this warning? I don't have any idea!
Best regards,
Torsten
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Closing modeless dialogs
- From: Torsten Hensel
- Re: Closing modeless dialogs
- References:
- Closing modeless dialogs
- From: Torsten Hensel
- Closing modeless dialogs
- Prev by Date: Re: Having a problem with CDC::StretchBlt
- Next by Date: Re: Can't read CString after serialization
- Previous by thread: Re: Closing modeless dialogs
- Next by thread: Re: Closing modeless dialogs
- Index(es):
Relevant Pages
|