• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1145
  • Last Modified:

How to Change Modless dialog to Modal

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
DOJI
Asked:
DOJI
  • 2
  • 2
1 Solution
 
northernchillCommented:
You can set the system modal style in the resource editor property pages for the dialog template.
0
 
knitzlCommented:
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
 
DOJIAuthor Commented:
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
 
northernchillCommented:
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
 
DOJIAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now