473,511 Members | 13,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modal dialogs hang up my program

Hello there,

I've encountered some strange behaviour. I display modal dialogs (using
ShowDialog) called from my mainform.
This is how the mainform is displayed out of the main sub of a module:
[vb]
Public fMain As frmMain

Public Sub Main()
Try
fMain = New frmMain
System.Windows.Forms.Application.Run(fMain)
Catch ex As Exception ' line c
MsgBox(ex.Message)
End Try
End Sub
[/vb]
and the modal dialog in frmMain:
[vb]
Private Sub MnuExtrasSettingsClick(sender As System.Object, _
e As System.EventArgs)

Try
Dim fSettings As New frmSettings
If fSettings.ShowDialog(Me) = DialogResult.OK Then ' Line a
' settings changed, load anew
LoadSettings(False)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub ' Line b
[/vb]
The dialog appears, but when close the button (whether with the OK or
Cancel-Button), the dialog closes and my app, too. The exception handler
of the main module displays "An external component raised an exception".
When I debug the prog, Line a displays the dialog, but when I close it,
jumps to Line b, and then to Line c (first source).
What am I doing wrong? (Accept- and CancelButton-properties of
frmSettings and the DialogResult-properties of the buttons are set).

When I copy the source from MnuExtrasSettingsClick to a timer tick event
and call it from MnuExtrasSettingsClick (Timer.Enabled = True), the
program does not crash.

What's wrong? I just don't understand it.
Thanks in advance,

Stefan

--
___________________________________www.VBTricks.de .vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
__________________________________________________ ___
Nov 21 '05 #1
1 1395
Hi,

I usually dont specify an owner when I use show dialog.

If fSettings.ShowDialog() = DialogResult.OK Then

Ken
---------------------
"VBTricks.de.vu Webmaster" <no****@thisserverdoesntexist.com> wrote in
message news:OK**************@TK2MSFTNGP12.phx.gbl...
Hello there,

I've encountered some strange behaviour. I display modal dialogs (using
ShowDialog) called from my mainform.
This is how the mainform is displayed out of the main sub of a module:
[vb]
Public fMain As frmMain

Public Sub Main()
Try
fMain = New frmMain
System.Windows.Forms.Application.Run(fMain)
Catch ex As Exception ' line c
MsgBox(ex.Message)
End Try
End Sub
[/vb]
and the modal dialog in frmMain:
[vb]
Private Sub MnuExtrasSettingsClick(sender As System.Object, _
e As System.EventArgs)

Try
Dim fSettings As New frmSettings
If fSettings.ShowDialog(Me) = DialogResult.OK Then ' Line a
' settings changed, load anew
LoadSettings(False)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub ' Line b
[/vb]
The dialog appears, but when close the button (whether with the OK or
Cancel-Button), the dialog closes and my app, too. The exception handler
of the main module displays "An external component raised an exception".
When I debug the prog, Line a displays the dialog, but when I close it,
jumps to Line b, and then to Line c (first source).
What am I doing wrong? (Accept- and CancelButton-properties of
frmSettings and the DialogResult-properties of the buttons are set).

When I copy the source from MnuExtrasSettingsClick to a timer tick event
and call it from MnuExtrasSettingsClick (Timer.Enabled = True), the
program does not crash.

What's wrong? I just don't understand it.
Thanks in advance,

Stefan

--
___________________________________www.VBTricks.de .vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
__________________________________________________ ___
Nov 21 '05 #2

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

Similar topics

3
2835
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...
10
2732
by: Guadala Harry | last post by:
I have a modal dialog that currently does all of the following except item 4. 1. lets users select a graphic from a list of thumbnails (and when selected, displays the full-size image in a...
1
1381
by: wendy | last post by:
I have got a problem while using the modal dialogs. In my code I need to open a modal dialog from the parent page and I need to enter some values in the dialog and save it. It takes the values...
2
3670
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...
0
7144
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...
1
7085
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
7512
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...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
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...
0
3227
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...
0
1577
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 ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
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...

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.