Link to home
Start Free TrialLog in
Avatar of nzfire
nzfire

asked on

Prevent ALT+F4 vb.net

Hi All,

I need to disable the use of Alt+F4 to close my app in vb.net.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bmwshadow00
Bmwshadow00

The answer above will work, but as an alternative method, you can use the FormClosing Event.

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If e.CloseReason = CloseReason.UserClosing Then
            e.Cancel = True
        End If
    End Sub

This will, however, also disable the ability to close the window via the X button, which may or may not be of use.