Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
' Code to Override the Alt-F4 keys combination
If e.KeyData = Keys.Alt + Keys.F4 Then
MessageBox.Show("Nice Try! You must log on with a password.", "Security", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
e.Handled = True
End If
End Sub
Code (VB.NET)
Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs) MyBase.OnKeyDown(e)
If (e.Alt AndAlso e.KeyCode = Keys.F4) Then
e.Handled = True
End If
End Sub