Solved

Modal vs Modeless Dialogs

Posted on 2001-06-27
7
498 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 178
dog bark java program 15 95
Bartender label printing - switch on and off graphics 3 38
Problem to App source 6 40
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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