Solved

modeless dialogs

Posted on 1998-12-04
1
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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
Expand macro to ask for filename column 8 40
Hibernate methods 2 87
has77  challenge 9 104
Problem to event 3 122
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Suggested Courses

732 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