Modal Forms

D

Dmitry Akselrod

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
 
S

Stoitcho Goutsev \(100\) [C# MVP]

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*
 
C

Cor Ligthert [MVP]

"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 said:
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
 
D

Dmitry Akselrod

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) said:
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 said:
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
 
D

Dmitry Akselrod

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) said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top