PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms ShowDialog and this.Modal

Reply

ShowDialog and this.Modal

 
Thread Tools Rate Thread
Old 08-12-2003, 12:36 PM   #1
Magnus Lindberg
Guest
 
Posts: n/a
Default ShowDialog and this.Modal


Hi,
I'm working on a larger windows application in which I have a form that should
behave as an mdi-child or as a dialog depending on how it is diplayed. I thought
I'd display the form with ShowDialog() to get it modal and then at runtime check
for this.Modal in the form and set some properties.
This however, does not seem to work as this.Modal returns false even though I'm
showing the form using its ShowDialog method.
Here's the conditional mentioned above, just to show the idea.

if (this.Modal)

{

this.ShowInTaskbar = false;

this.MaximizeBox = false;

this.MinimizeBox = false;

this.FormBorderStyle = FormBorderStyle.FixedDialog;

this.SaveButton.Visible = false;

this.ChooseButton.DialogResult = DialogResult.OK;

foreach (Control ctrl in this.Controls)

ctrl.Left -= 72;

}


Thanks,

--
Magnus Lindberg, MCSD, MCT


  Reply With Quote
Old 08-12-2003, 12:42 PM   #2
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
Default Re: ShowDialog and this.Modal

* "Magnus Lindberg" <magnus.lindberg@inospam> scripsit:
> I'm working on a larger windows application in which I have a form that should
> behave as an mdi-child or as a dialog depending on how it is diplayed. I thought
> I'd display the form with ShowDialog() to get it modal and then at runtime check
> for this.Modal in the form and set some properties.
> This however, does not seem to work as this.Modal returns false even though I'm
> showing the form using its ShowDialog method.


You cannot show a MDI child modally.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
  Reply With Quote
Old 08-12-2003, 01:03 PM   #3
Magnus Lindberg
Guest
 
Posts: n/a
Default Re: ShowDialog and this.Modal

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23I6oPkYvDHA.3532@TK2MSFTNGP11.phx.gbl...
> * "Magnus Lindberg" <magnus.lindberg@inospam> scripsit:
> > I'm working on a larger windows application in which I have a form that

should
> > behave as an mdi-child or as a dialog depending on how it is diplayed. I

thought
> > I'd display the form with ShowDialog() to get it modal and then at runtime

check
> > for this.Modal in the form and set some properties.
> > This however, does not seem to work as this.Modal returns false even though

I'm
> > showing the form using its ShowDialog method.

>
> You cannot show a MDI child modally.
>
> --
> Herfried K. Wagner [MVP]
> <http://www.mvps.org/dotnet>


But in the case where the form is shown modally, it is not an MDI child.
The application either sets the MdiParent property of the form and display it
with Show(), or it doesn't bother with MdiParent and just calls ShowDialog().
The form, when displayed with ShowDialog is clearly modal since I can't interact
with any other part of the application, yet this.Modal in the forms constructor
returns false.
I'm beginning to think that I have to check the Modal-property from outside of
the form.


--
Magnus Lindberg, MCSD, MCT
cshrp.net - "Elegant code by witty programmers"


  Reply With Quote
Old 08-12-2003, 01:57 PM   #4
Eric Newton
Guest
 
Posts: n/a
Default Re: ShowDialog and this.Modal

Maybe try checking the mdiParent property for the same logic?

Just a thought...


--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
eric@cc.ensoft-software.com [remove the first "CC."]

"Magnus Lindberg" <magnus.lindberg@inospam> wrote in message
news:OYyXPuYvDHA.1744@TK2MSFTNGP12.phx.gbl...
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:%23I6oPkYvDHA.3532@TK2MSFTNGP11.phx.gbl...
> > * "Magnus Lindberg" <magnus.lindberg@inospam> scripsit:
> > > I'm working on a larger windows application in which I have a form

that
> should
> > > behave as an mdi-child or as a dialog depending on how it is diplayed.

I
> thought
> > > I'd display the form with ShowDialog() to get it modal and then at

runtime
> check
> > > for this.Modal in the form and set some properties.
> > > This however, does not seem to work as this.Modal returns false even

though
> I'm
> > > showing the form using its ShowDialog method.

> >
> > You cannot show a MDI child modally.
> >
> > --
> > Herfried K. Wagner [MVP]
> > <http://www.mvps.org/dotnet>

>
> But in the case where the form is shown modally, it is not an MDI child.
> The application either sets the MdiParent property of the form and display

it
> with Show(), or it doesn't bother with MdiParent and just calls

ShowDialog().
> The form, when displayed with ShowDialog is clearly modal since I can't

interact
> with any other part of the application, yet this.Modal in the forms

constructor
> returns false.
> I'm beginning to think that I have to check the Modal-property from

outside of
> the form.
>
>
> --
> Magnus Lindberg, MCSD, MCT
> cshrp.net - "Elegant code by witty programmers"
>
>



  Reply With Quote
Old 08-12-2003, 07:12 PM   #5
Doug Forster
Guest
 
Posts: n/a
Default Re: ShowDialog and this.Modal

Hi Magnus,

Why don't you just write your own Show method and set a flag before calling
ShowDialog.

Cheers

Doug Forster

"Magnus Lindberg" <magnus.lindberg@inospam> wrote in message
news:OYyXPuYvDHA.1744@TK2MSFTNGP12.phx.gbl...
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:%23I6oPkYvDHA.3532@TK2MSFTNGP11.phx.gbl...
> > * "Magnus Lindberg" <magnus.lindberg@inospam> scripsit:
> > > I'm working on a larger windows application in which I have a form

that
> should
> > > behave as an mdi-child or as a dialog depending on how it is diplayed.

I
> thought
> > > I'd display the form with ShowDialog() to get it modal and then at

runtime
> check
> > > for this.Modal in the form and set some properties.
> > > This however, does not seem to work as this.Modal returns false even

though
> I'm
> > > showing the form using its ShowDialog method.

> >
> > You cannot show a MDI child modally.
> >
> > --
> > Herfried K. Wagner [MVP]
> > <http://www.mvps.org/dotnet>

>
> But in the case where the form is shown modally, it is not an MDI child.
> The application either sets the MdiParent property of the form and display

it
> with Show(), or it doesn't bother with MdiParent and just calls

ShowDialog().
> The form, when displayed with ShowDialog is clearly modal since I can't

interact
> with any other part of the application, yet this.Modal in the forms

constructor
> returns false.
> I'm beginning to think that I have to check the Modal-property from

outside of
> the form.
>
>
> --
> Magnus Lindberg, MCSD, MCT
> cshrp.net - "Elegant code by witty programmers"
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off