DOJI
asked on
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
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
You can set the system modal style in the resource editor property pages for the dialog template.
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.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Thanks for your suggestions