Solved

Modal vs Modeless Dialogs

Posted on 2001-06-27
7
503 Views
Last Modified: 2013-11-20
Dear Experts,

I am using VC++6/MFC Win 98.

I would like to know if it is possible to make a Dialog Object which can act both modally & modelessly.

i.e Display the Object using both the following methods:

1. MyDialog.DoModal().
2. MyDialog = new CMyDialog(this,...)

If so, how do I detect which it is in the Dialog Constructor?

For modeless dialogs, I normally use the follwing code to create & show the dialog object:

CMyDialog(CWnd* pParent,...)
{
Create(this,CMyDialog::IDD);
ShowWindow(SW_SHOW);
}

Obviously, I don't need to execute the Create & ShowWindow commands if the dialog is Modal.
So, I need some way of detecting if Dialog is Modal or not.

I look forward to you answers.

Bean
0
Comment
Question by:beanjasper
  • 3
  • 3
7 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6230330
There may be a simple build-in command, but the easiset would be to simply add a variable, m_fIsModal to the derived class.  Then...

  m_dlg= new CMyDlg(...)
  m_dlg.m_fIsModal= TRUE;
  m_dlg.DoModal();
or
  m_dlg= new CMyDlg(...)
  m_dlg.m_fIsModal= FALSE;
  m_dlg.Create(...

-- Dan
0
 

Author Comment

by:beanjasper
ID: 6230653
Hi Dan,

Thats so simple I'm embarassed!

If you don't mind, I'll leave this question open for a couple of days to see if anyone knows of a 'Built In' function.

If not, the points are yours.

Thanks

Bean
0
 
LVL 32

Expert Comment

by:jhance
ID: 6231205
Perhaps there is a flag buried in the data returned by GetWindowLongPtr() that specifies modal vs. non-modal.  

Obviously Windows knows which it is and the information is almost certainly kept in the window itself...

Just a thought.
0
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!

 
LVL 49

Expert Comment

by:DanRollins
ID: 6232533
Actually Windows probably doesn't know -- It just sends messages.  MFC uses a technique in which all dialog boxes are actually modeless -- MFC does *not* call the DialoxBox API (which implements an interal message pump).  MFC wants more control so it implements its own message pump to simulate "Modal Dialog" type action.

You could take a look at the m_nFlags member.  I think that if...
   (m_nFlags & WF_CONTINUEMODAL) != 0
then it is a modal dialog.

-- Dan

0
 

Author Comment

by:beanjasper
ID: 6234346
Dan

m_nFlags - Is this a member of CDialog or is it inherited from CWnd?

I can't find mention of it in the CDialog or CWnd documentation.

Also, where is the list of WF_.. flags such as the one you mentioned above?

I have bumped the points to 75 to recompense you for the extra time required to answer these.

Thanks

Bean
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 75 total points
ID: 6237042
It appears that these flags are not officially documented.  However m_nFlags is a public data member of CWnd.  You can find the flag value constants in the file AFXWIN.H, in the  ... \MFC\Include directory.


You can also glean a little more info by searching MDSN for m_fFlags

-- Dan
0
 

Author Comment

by:beanjasper
ID: 6237103
Yup, 10/10!

Heres an A for your troubles.

Thanks

Bean
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 152
Execute multiple curl cmds with sleep and send output to file 10 113
wordcount challenge 11 144
unix example issues 18 106
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…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

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