G
gsb58
Hi!
In my application I have code that will give the user a choice when he
click's the close button on the ToolBar1.
However, when he clicks the close button of the form, the form will
shut down even if he chooses the cancel button of the messagebox that
pop's up.
Now...if he, on the other hand, chooses ALT+F4, then I catch this in
code and then the cancel button works very well. The code goes like:
Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Try
If (e.Alt) = Keys.F4 Then
MyShuttingDownAction()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "HEY!", MessageBoxButtons.OK,
MessageBoxIcon.Warning)
End Try
End Sub
So I've tried to catch the form's close button in the form's OnClosing
event, but it doesn't respond to the code I've written, which goes like
this:
Public Sub MyShuttingDownAction()
Dim intRes As Integer
Try
intRes = MessageBox.Show("U LEAVE ME?", _
"BYE?", _
MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If intRes = DialogResult.Cancel Then
StatusBar1.Panels(4).Text = "STILL HERE?"
ElseIf intRes = DialogResult.OK Then
Application.Exit()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "HEY!", MessageBoxButtons.OK,
MessageBoxIcon.Warning)
End Try
End Sub
Hope anybody could point me in the right direction.
Me.Name
In my application I have code that will give the user a choice when he
click's the close button on the ToolBar1.
However, when he clicks the close button of the form, the form will
shut down even if he chooses the cancel button of the messagebox that
pop's up.
Now...if he, on the other hand, chooses ALT+F4, then I catch this in
code and then the cancel button works very well. The code goes like:
Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Try
If (e.Alt) = Keys.F4 Then
MyShuttingDownAction()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "HEY!", MessageBoxButtons.OK,
MessageBoxIcon.Warning)
End Try
End Sub
So I've tried to catch the form's close button in the form's OnClosing
event, but it doesn't respond to the code I've written, which goes like
this:
Public Sub MyShuttingDownAction()
Dim intRes As Integer
Try
intRes = MessageBox.Show("U LEAVE ME?", _
"BYE?", _
MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If intRes = DialogResult.Cancel Then
StatusBar1.Panels(4).Text = "STILL HERE?"
ElseIf intRes = DialogResult.OK Then
Application.Exit()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "HEY!", MessageBoxButtons.OK,
MessageBoxIcon.Warning)
End Try
End Sub
Hope anybody could point me in the right direction.
Me.Name