Hi Everyone,

I am working in VB.NET, Framework v.1.0. I have tons of forms in my
application. I have a situation, where a form starts another form as a
Modal Dialog. The Modal Dialog then possibly starts another form as Modal
Dialog. Thus, if the main form is frmMain, and the other two forms are
frmOne and frmTwo, then frmMain calls frmOne.ShowDialog(me) and frmOne calls
frmTwo.ShowDialog(me).

My problem is that when frmTwo is closed or hidden, frmOne also closes or
hides. I would like to prevent this from happening. I tried setting the
forms TopMost. I tried using the SetWindowsPos API call to mess with the
Z-Order of the forms. I tried to just use the frm.Show() method and attempt
to emulate a Modal dialog with trickery. Nothing seems to quite accomplish
what I am trying to do. Can someone please help?

Thanks,

dmitry

Re: Modal Forms by Stoitcho

Stoitcho
Mon Dec 12 10:05:26 CST 2005

Dimitry,

I don't have v1.0 and all that I'm going to say is based on my test agains
1.1; hope it applies for 1.0.

1. In order not to get doalog boxes minimize together and to have the dialog
above its parent show the dialog like this

dlg.ShowDialog(this);

where *dlg* is reference to the dialog box form and *this* is reference to
the parent form (assuming) that the method where ShowDialog is called is
member of the parent form class.

2. As far as it goes for the problem with closing both forms when the top
one is closed it shouldn't happen. If you show the form when the user clicks
on a button check if the button has DialogResult property set. If it has it
will happen. Set the DailogResult of the button to *none*


--
HTH
Stoitcho Goutsev (100) [C# MVP]

--

Stoitcho Goutsev (100) [C# MVP]

"Dmitry Akselrod" <dmitry@nospam.com> wrote in message
news:WqSdnXiZTYbuzwfenZ2dnUVZ_tadnZ2d@comcast.com...
> Hi Everyone,
>
> I am working in VB.NET, Framework v.1.0. I have tons of forms in my
> application. I have a situation, where a form starts another form as a
> Modal Dialog. The Modal Dialog then possibly starts another form as Modal
> Dialog. Thus, if the main form is frmMain, and the other two forms are
> frmOne and frmTwo, then frmMain calls frmOne.ShowDialog(me) and frmOne
> calls frmTwo.ShowDialog(me).
>
> My problem is that when frmTwo is closed or hidden, frmOne also closes or
> hides. I would like to prevent this from happening. I tried setting the
> forms TopMost. I tried using the SetWindowsPos API call to mess with the
> Z-Order of the forms. I tried to just use the frm.Show() method and
> attempt to emulate a Modal dialog with trickery. Nothing seems to quite
> accomplish what I am trying to do. Can someone please help?
>
> Thanks,
>
> dmitry
>



Re: Modal Forms by Stoitcho

Stoitcho
Mon Dec 12 10:08:14 CST 2005

Please, don't "cross post".


--

Stoitcho Goutsev (100) [C# MVP]

"Dmitry Akselrod" <dmitry@nospam.com> wrote in message
news:WqSdnXiZTYbuzwfenZ2dnUVZ_tadnZ2d@comcast.com...
> Hi Everyone,
>
> I am working in VB.NET, Framework v.1.0. I have tons of forms in my
> application. I have a situation, where a form starts another form as a
> Modal Dialog. The Modal Dialog then possibly starts another form as Modal
> Dialog. Thus, if the main form is frmMain, and the other two forms are
> frmOne and frmTwo, then frmMain calls frmOne.ShowDialog(me) and frmOne
> calls frmTwo.ShowDialog(me).
>
> My problem is that when frmTwo is closed or hidden, frmOne also closes or
> hides. I would like to prevent this from happening. I tried setting the
> forms TopMost. I tried using the SetWindowsPos API call to mess with the
> Z-Order of the forms. I tried to just use the frm.Show() method and
> attempt to emulate a Modal dialog with trickery. Nothing seems to quite
> accomplish what I am trying to do. Can someone please help?
>
> Thanks,
>
> dmitry
>



Re: Modal Forms by Cor

Cor
Mon Dec 12 12:02:14 CST 2005


"Stoitcho Goutsev (100) [C# MVP]"
.
> Please, don't "cross post".
>

Why not most people advice that in the dotNet newsgroups to *relevant*
groups instead of multipost?

I agree with you that the C# newsgroup is in this case almost completely
irrelevant.

For the rest, because that I tested the problem of the OP and had the same
problem as he, do I find it completely relevant as I see how many answers he
got. However because it is so od, I had expected more answers. Your first
one was one that was for me probably in the right direction (there is an old
bug in this area).

Cor


> Stoitcho Goutsev (100) [C# MVP]
>
> "Dmitry Akselrod" <dmitry@nospam.com> wrote in message
> news:WqSdnXiZTYbuzwfenZ2dnUVZ_tadnZ2d@comcast.com...
>> Hi Everyone,
>>
>> I am working in VB.NET, Framework v.1.0. I have tons of forms in my
>> application. I have a situation, where a form starts another form as a
>> Modal Dialog. The Modal Dialog then possibly starts another form as
>> Modal Dialog. Thus, if the main form is frmMain, and the other two
>> forms are frmOne and frmTwo, then frmMain calls frmOne.ShowDialog(me) and
>> frmOne calls frmTwo.ShowDialog(me).
>>
>> My problem is that when frmTwo is closed or hidden, frmOne also closes or
>> hides. I would like to prevent this from happening. I tried setting the
>> forms TopMost. I tried using the SetWindowsPos API call to mess with the
>> Z-Order of the forms. I tried to just use the frm.Show() method and
>> attempt to emulate a Modal dialog with trickery. Nothing seems to quite
>> accomplish what I am trying to do. Can someone please help?
>>
>> Thanks,
>>
>> dmitry
>>
>
>



Re: Modal Forms by Dmitry

Dmitry
Mon Dec 12 21:18:29 CST 2005

Hi,

Your suggestion worked like a charm. I did something stupid and copied the
cancel button from another form. The cancel button had the DialogResult
property set.

Sorry about multiposting. I figured that my question was relevant to all
the groups.

Thanks again for your help!

dmitry

"Stoitcho Goutsev (100) [C# MVP]" <100@100.com> wrote in message
news:uZegfWz$FHA.2708@TK2MSFTNGP12.phx.gbl...
> Dimitry,
>
> I don't have v1.0 and all that I'm going to say is based on my test agains
> 1.1; hope it applies for 1.0.
>
> 1. In order not to get doalog boxes minimize together and to have the
> dialog above its parent show the dialog like this
>
> dlg.ShowDialog(this);
>
> where *dlg* is reference to the dialog box form and *this* is reference to
> the parent form (assuming) that the method where ShowDialog is called is
> member of the parent form class.
>
> 2. As far as it goes for the problem with closing both forms when the top
> one is closed it shouldn't happen. If you show the form when the user
> clicks on a button check if the button has DialogResult property set. If
> it has it will happen. Set the DailogResult of the button to *none*
>
>
> --
> HTH
> Stoitcho Goutsev (100) [C# MVP]
>
> --
>
> Stoitcho Goutsev (100) [C# MVP]
>
> "Dmitry Akselrod" <dmitry@nospam.com> wrote in message
> news:WqSdnXiZTYbuzwfenZ2dnUVZ_tadnZ2d@comcast.com...
>> Hi Everyone,
>>
>> I am working in VB.NET, Framework v.1.0. I have tons of forms in my
>> application. I have a situation, where a form starts another form as a
>> Modal Dialog. The Modal Dialog then possibly starts another form as
>> Modal Dialog. Thus, if the main form is frmMain, and the other two
>> forms are frmOne and frmTwo, then frmMain calls frmOne.ShowDialog(me) and
>> frmOne calls frmTwo.ShowDialog(me).
>>
>> My problem is that when frmTwo is closed or hidden, frmOne also closes or
>> hides. I would like to prevent this from happening. I tried setting the
>> forms TopMost. I tried using the SetWindowsPos API call to mess with the
>> Z-Order of the forms. I tried to just use the frm.Show() method and
>> attempt to emulate a Modal dialog with trickery. Nothing seems to quite
>> accomplish what I am trying to do. Can someone please help?
>>
>> Thanks,
>>
>> dmitry
>>
>
>