473,394 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Modal Forms

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
Dec 10 '05 #1
5 3548
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" <dm****@nospam.com> wrote in message
news:Wq******************************@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

Dec 12 '05 #2
Please, don't "cross post".
--

Stoitcho Goutsev (100) [C# MVP]

"Dmitry Akselrod" <dm****@nospam.com> wrote in message
news:Wq******************************@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

Dec 12 '05 #3

"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" <dm****@nospam.com> wrote in message
news:Wq******************************@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


Dec 12 '05 #4
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]" <10*@100.com> wrote in message
news:uZ**************@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" <dm****@nospam.com> wrote in message
news:Wq******************************@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


Dec 13 '05 #5
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]" <10*@100.com> wrote in message
news:uZ**************@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" <dm****@nospam.com> wrote in message
news:Wq******************************@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


Dec 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hector | last post by:
I have a ComboBox set up in a non-modal form. When a selection is made from the ComboBox, the handler code closes the form, but then the system crashes because of an unhandled NullReferenceException....
3
by: Andrew | last post by:
I get a Null Reference Exception if I close a non-modal dialog (that is, a form opened with Show()) when a selection is made from a ComboBox. The error message refers to Unsafe Native Methods, but...
2
by: cassidyc | last post by:
Hi, I was wondering if anyone has come accross this issue? And if they have any solutions I have that can create new copies of itself Form1 as = new form1(); af.show(); This form can also...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
2
by: Mike | last post by:
Hi, I'm having a problem with modal forms on windows. I've written a very short test program, with a main window and a form called from the main window. The form is set to modal with...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have...
2
by: diogenes | last post by:
I have created many shortcut/popup (aka context, or right-click) menus for my application - instead of toolbars or standard drop-down menus. Within my custom menu, I am using...
4
by: =?Utf-8?B?Z2luYWNyZXNzZQ==?= | last post by:
I am trying to close/dispose multiple instances of a form but because they are modal and hidden, they do not show up in My.Application.OpenForms. They must be modal, so making them modeless is not...
1
by: Mohit | last post by:
Hi all, I am working on a windows based client server application with multiple forms. All forms are having custom title bars with no default bars. There is one main form. Some forms are opened up...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.