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.Applicati on.Run(fMain)
Catch ex As Exception ' line c
MsgBox(ex.Messa ge)
End Try
End Sub
[/vb]
and the modal dialog in frmMain:
[vb]
Private Sub MnuExtrasSettin gsClick(sender As System.Object, _
e As System.EventArg s)
Try
Dim fSettings As New frmSettings
If fSettings.ShowD ialog(Me) = DialogResult.OK Then ' Line a
' settings changed, load anew
LoadSettings(Fa lse)
End If
Catch ex As Exception
MsgBox(ex.Messa ge)
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 MnuExtrasSettin gsClick to a timer tick event
and call it from MnuExtrasSettin gsClick (Timer.Enabled = True), the
program does not crash.
What's wrong? I just don't understand it.
Thanks in advance,
Stefan
--
_______________ _______________ _____www.VBTric ks.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
_______________ _______________ _______________ ________