Modeless Dialogs and MFC - How?

Started by
3 comments, last by Evil Bill 21 years, 7 months ago
How do you create a modelss dialog with MFC? I know you can use CDialog::DoModal() to create a modal one, but the MSDN says to use CDialog::Create(). If i use that, i need to use new to create the dialog, otherwise it goes out of scope and closes. The problem is that OnDestroy() isn''t ever called, and i get a message in the debug output saying:
quote: Warning: calling DestroyWindow in CDialog::~CDialog -- OnDestroy or PostNcDestroy in derived class will not be called.
Has anyone ever managed to get modelss dialogs working? Cheers, Steve Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
Advertisement
A search on google for "modeless dialog mfc" turns up several links, including several msdn pages...

Among the results was:

http://www.codeproject.com/dialog/modelesssibling.asp

Also, for MFC stuff generally try www.codeguru.com, they usually have some good stuff, for example, http://codeguru.earthweb.com/propertysheet/modeless_wizard.shtml

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Thanks, I''ll take a look at the code project link. I actually had a look at CodeGuru.com, and didn''t see anything of much use.

Cheers,
Steve

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
May be able to answer your Q:
[from the MSDN CDialog front page]

When you implement a modeless dialog box, always override the OnCancel member function and call DestroyWindow from within it. Don''t call the base class CDialog::OnCancel, because it calls EndDialog, which will make the dialog box invisible but will not destroy it. You should also override PostNcDestroy for modeless dialog boxes in order to delete this, since modeless dialog boxes are usually allocated with new. Modal dialog boxes are usually constructed on the frame and do not need PostNcDestroy cleanup.

[/from the MSDN CDialog front page]

I would like to know (on a related yet selfishly thread hijacking matter) how to communicate between the main prog and the modeless box. For example in a drawing program which requires properties of a graphics object; the dialog box for example has an x and y edit box... How do i update the main prog on manipulation of the box values?
quote:Original post by TheHermit
I would like to know (on a related yet selfishly thread hijacking matter) how to communicate between the main prog and the modeless box. ...How do i update the main prog on manipulation of the box values?

TN026: DDX and DDV Routines

Alternatively, define a user message and use that (along with PostMessage) to pass data between the dialog and the main window.

This topic is closed to new replies.

Advertisement