Solved

modeless dialogs

Posted on 1998-12-04
1
334 Views
Last Modified: 2013-11-20
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 ? ..................
0
Comment
Question by:sunraj
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1325776
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 ) ;
or
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).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 136
sumNumber challenge 16 140
scoreUp challenge 14 68
JQuery serialize and unserialize 8 180
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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