[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

modeless dialogs

Posted on 1998-12-04
1
Medium Priority
?
344 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 100 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

873 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