modeless dialogs

hi regards!
i already asked this question, but i didn't get convincing reply. Please do explain modeless dialog, the arguments
passed to it's create member function. Please cite an
example. Is it a must to allocate dynamically the memmory for modeless dialogs ? ..................
Who is Participating?
Answers2000Connect With a Mentor Commented:
A modeless dialog is one which need not be completed before the user can continue work in the application.

The Create function simply takes the resource id of the dialog in the resource file (usually beginning IDD_) and optionally the parent window (CWnd *)

BOOL bCreate = dlg.Create( IDD_DIALOG1, pWnd ) ;
BOOL bCreate = dlg.Create( IDD_DIALOG1 ) ;

bCreate is set to TRUE if the dialog was created okay.

The dialog the continues processing messages, while the rest of the app can to.

When you close the modeless dialog, you mustn't use the EndDialog API to do it.  Basically this function is called by CDialog::EndDialog, CDialog::OnOK and CDialog::OnCancel.  Avoid these functions like the plague for modeless dialogs.

Instead use DestroyWindow() ; to kill the modeless dialog.  You can call this within the dialog, or from another piece of code in your app.

And no it is not necessary to dynamically allocate memory the modeless dialog.  What you do need to is make sure the memory for the dialog class is not free'd before the dialog exits, and dynamically allocating is an easy way around this.

For example

void SomeFunc()
   CMyDialog oDlg ;

   oDlg.Create( IDD_DIALOG1 ) ;

At the second } oDlg goes out of scope, meaning the variable is freed.  This is bad news as the dialog is still displayed and executing.  Therefore it a good way round this is to dynamically allocate the memory (using new) and free it later (using delete).
All Courses

From novice to tech pro — start learning today.