?
Solved

How to Change Modless dialog to Modal

Posted on 2003-02-21
7
Medium Priority
?
1,133 Views
Last Modified: 2013-11-20
Hi there,
I want to switch the style of my dialog based application form Modless to Sytem Modal. I tried setting 'DS_SYSMODAL' flag in my InitDialog function
BOOL CMyDlg::OnInitDialog()
{
  DWORD style= this->GetStyle( );
  if(!(style & DS_SYSMODAL)){
     DWORD dwAdd = DS_SYSMODAL    ;
     this->ModifyStyleEx( 0, dwAdd, 0 );
  }
  CDialog::OnInitDialog();
}
This seems to set the style, but the displayed window is still Modless!! Isn't this a valid flag? or Am I doing this very late??
Is there any other way to achieve this?
Thanks for your help
Jijo
0
Comment
Question by:DOJI
[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
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:northernchill
ID: 7994823
You can set the system modal style in the resource editor property pages for the dialog template.
0
 

Expert Comment

by:knitzl
ID: 7998530
It's been a while, but I think it's more how you invoke the display of the dialog box.  Use CDialog::DoModal() to invoke it and you'll get modal behavior.
0
 

Author Comment

by:DOJI
ID: 8007406
Hi northernchill,
Changing in Resource Editor is not an option. I want to do it dynamically sometimes modal and sometimes modeless.
Hi knitzl,
I am using DoModal() to inovoke the dialog. It invokes the dialog based on the property set in resource editor. In my resource editor the property is set to 'System Modal', I need to change the dialog to 'Modless' on certain condtions.
Thanks for the reply
Jijo
0
 
LVL 2

Accepted Solution

by:
northernchill earned 100 total points
ID: 8008698
I am a little confused, in your resource editor the System Modal property is set?  

If this is the case, when you want it to be modeless, do not call DoModal(), simply instantiate the object, create the window and then call ShowWindow().  This is how I normally display modeless dialogs.

if(!m_SearchDialog.m_hWnd)
   m_SearchDialog.Create((UINT)IDD_SEARCHDLG);

m_SearchDialog.ShowWindow(SW_SHOW);

Then when you want it to be modal,

m_SearchDialog.Create((UINT)IDD_SEARCHDLG);
m_SearchDialog.DoModal();

0
 

Author Comment

by:DOJI
ID: 8016997
Thanks northernchill, this will work. But on a second thought,I think, for my application it would be better to switch the dialog between 'Modal' and 'SystemModal'. In that case you can't use ShowWindow call. Is this possible to change a dialog to SystemModal after calling DoModal? Or By overriding DoModal function?? Or by setting some flag or changing the style??
Thanks for your suggestions
0

Featured Post

Independent Software Vendors: 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

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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

764 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