?
Solved

Modal vs Modeless Dialogs

Posted on 2001-06-27
7
Medium Priority
?
528 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
[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
  • 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 300 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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: 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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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