473,624 Members | 2,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using multiple modal dialogs in a Windows app

Hello,

I have a Windows form that opens a modal dialog window. From there I
can open yet another modal dialog window so I can grab some info to
pass back to the first dialog. Both need to be modal and are launched
like this:
>From my main Windows form:
if (formName1.Show Dialog( this ) == DialogResult.OK )
......
>From formName1:
if (formName2.Show Dialog( this ) == DialogResult.OK )
......

I have OK buttons on both modal forms that return a DialogResult of OK
and then they do formName.Close( ). They both also have a Cancel
button with simply a formName.Close( ).

My problem is when I close the second dialog window via either a
Cancel or OK, the first one closes with it, and I would like for the
first to stay open :)

Does anyone have any ideas?

Mike

Sep 6 '07 #1
1 3789
On 6 Sep., 04:42, Mike <mccar...@hotma il.comwrote:
Hello,

I have a Windows form that opens a modal dialog window. From there I
can open yet another modal dialog window so I can grab some info to
pass back to the first dialog. Both need to be modal and are launched
like this:
From my main Windows form:

if (formName1.Show Dialog( this ) == DialogResult.OK )
......
From formName1:

if (formName2.Show Dialog( this ) == DialogResult.OK )
......

I have OK buttons on both modal forms that return a DialogResult of OK
and then they do formName.Close( ). They both also have a Cancel
button with simply a formName.Close( ).

My problem is when I close the second dialog window via either a
Cancel or OK, the first one closes with it, and I would like for the
first to stay open :)

Does anyone have any ideas?

Mike
I tried reproducing the problem you describe, but it seems to work
fine for me.
Creating 3 windows, each with a button with its DialogResult-Property
set to OK, the first one calling ShowDialog on the second and the
second on the third, behave exactly as expected.
Could you post a short program that still causes the unexpected
behavior?
As a sidenote: You don't actually have to call Close on the form
within a button's click-event if the button has a DialogResult
associated with it, the form will close automatically after the button
is pressed.

Kevin Wienhold

Sep 6 '07 #2

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

Similar topics

2
7157
by: Bjoern Obermeyer | last post by:
Hi, I am writing an application with a JFrame as the main window and several dialogs to gain user input. The problem arises when another window (from a differnent apllication) hides my applications window (while one of the (modal) dialogs is currently showing). When my applications window reappears again the dialog is no longer showing. I have to iconify the other applications window in order to make the dialog reappear again. What do...
3
2844
by: Andrew Baker | last post by:
OK this has me perplexed, puzzled and bamboozled! I have a remoting service which I displayed a message box in. I then wondered what would happen if a client made a call to the service while the message box was being displayed. Since the call comes in on a different thread the client call was not blocked. This seemed to make sense to me. Next I thought, what will happen when the client calls into the server if I try to use a delegate...
5
3860
by: MrNobody | last post by:
I am using the no-arg ShowDialog() method hoping that the window would not be modal to any other window like the other ShowDialog(IWin32Window) method does, but when this opens it somehow becomes modal to my main window- even though I don't see how it could even be getting a reference to my main window. What I need is to open a new window but still have my main window available for interaction- the way it opens now it forces focus on this...
2
2554
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)
1
8065
by: SammyBar | last post by:
Hi all, I'm having troubles with a Symbol 9000 device (Compact Framework v 1.1) when activating the barcode scanner from a window. The problem is related to the Activated event of the form which carries the task of the initializing the scanner. It looks like this event is not called after the creation of one of the forms. Let me describe shortly the sequence of form creation. The app first call a browsing form by using ShowDialog()....
2
3680
by: sthrudel | last post by:
Hi! I'm working on a web application in Asp.net and what I would like to have is a cross borwser modal dialog which accepts user's input. I would like to catch what the user clicked on the dialog. To be more specific I want to have a confirmation dialog that is shown when a user clicks on a Delete button (which deletes some values from database). If Yes is pressed the delete action is processed otherwise modal dialog is closed.
10
4834
by: bern11 | last post by:
If Form1 opens Form2 modally, how do I capture clicks on Form1 when Form2 is open? I want to click on Form1 and read the mouse co-ordinates into Form2. Since Form2 is open modally, Form1 mouse-events do not fire. What events on Form2 fire? I could open Form2 modelessly, then process from within Form1 mouse events. Is there any other way?
7
1587
by: proximus | last post by:
hello i need some modal dialog box to show when page is loaded any sugestion? not 'onclik' thanks -- www.proximus-os.hr ; www.e-stranica.com ; www.zlatovezi.com
1
3561
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
8179
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
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8341
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
8490
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...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
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
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.