Handling exit (X) button at the top right corner
-
Hi, As per my requirement is concerned ,When I press the close(X) button at the top right corner , I need a dialog box to be displayed.Where should I handle (add the code for) this ? Hope I am clear. Thanks in advance.
Taruni
-
Hi, As per my requirement is concerned ,When I press the close(X) button at the top right corner , I need a dialog box to be displayed.Where should I handle (add the code for) this ? Hope I am clear. Thanks in advance.
Taruni
You need to catch the (On_Close) event for the close button.
Private Sub OnClosingForm() Dim Result As DialogResult Result = MessageBox.Show("Are you sure you with to exit Time-Keeper?" & vbCrLf & _ "Press OK to Exit & Close, Press No to mimimise to the system tray.", "Confirmation on action!", _ MessageBoxButtons.YesNo, MessageBoxIcon.Question) If Result = Windows.Forms.DialogResult.Yes Then Me.Close() Else Me.WindowState = FormWindowState.Minimized Me.Hide() End If End Sub Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Me.Dispose() End Sub This is a code and not a Vista question, if you have further question please post on a form dedicated to your chosen language (C# or VB.Net). Hope this helps.
When people make you see red, be thankful your not colour blind.