473,729 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ShowDial og(me) and frmOne calls
frmTwo.ShowDial og(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 3563
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.ShowDial og(me) and frmOne
calls frmTwo.ShowDial og(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.ShowDial og(me) and frmOne
calls frmTwo.ShowDial og(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.ShowDial og(me) and
frmOne calls frmTwo.ShowDial og(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******** ******@TK2MSFTN GP12.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.ShowDial og(me) and
frmOne calls frmTwo.ShowDial og(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******** ******@TK2MSFTN GP12.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.ShowDial og(me) and
frmOne calls frmTwo.ShowDial og(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
413
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. There is a reference to Unsafe Native Methods and Callback functions, but Interop Services are not used. What is going on ? The problem does not occur if the form is made modal. Any thoughts would be appreciated. The code appears below for a simple...
3
8150
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 the code is 100% managed. The exception is not thrown if the dialog was modal (opened with ShowDialog()) or if the selection is made from, say, a ListBox. I have included a simple example below. I am using C#.NET 2003, Standard Edition.
2
2559
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 bring up a modal dialog (MessageBox)
8
2735
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 thread to access the database and then displays a modal dialog which allows the user to cancel the task, if it is taking longer than they want, and shows them a display of how long the query has been running so far.
2
2645
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 form.setModal(1) before calling form.show(). All works as expected on Linux. The form is modal, not allowing the main window to received the focus. If I call the form from within itself, the topmost form is modal, and not of the previous forms will...
2
4501
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 boxes (please see associated source code below): 1) Win32 API with context ("btnWin32WithContext_Click") 2) .NET Framework with context ("btnFrameworkWithContext_Click") 3) Win32 API withOUT context ("btnWin32WithOUTContext_Click")
11
2374
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 realized that despite suggestions to use DHTML-based modal dialogs are very common? there is not a single fully functional reliable copyright-free cross-browser alternative to say MsgBox (VBScript) or showModalDialog (IE). This way such suggestions up to...
2
3515
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 =ShowMainMenu("item") in the On Action event where ShowMainMenu is a public function in frmMain, and "item" is a string mapping to a button click event. (error trapping omitted) Public Function ShowMainMenu(strItem As String) As Boolean
4
4554
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 an option. I also need to check the values in a spread control on the forms before I close/dispose them. I'm using VB 2005. Is there some way for me to do this?
1
3563
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 as modal while others are opened up as modeless on this main form. Whenever some error occurs in client server communication we show it in modal message box. Now I ran into a case: a modal form is opened up on the main form. And some error...
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9280
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.