Hello!
I want in my vb.net application that user can not close the application simply by using ALT + F4 from keyboard unless he enters the correct password!
Anyone know how to do this?
Printable View
Hello!
I want in my vb.net application that user can not close the application simply by using ALT + F4 from keyboard unless he enters the correct password!
Anyone know how to do this?
In the form's 'Closing' event handler, set 'e.Cancel = True' to stop
closing the form.
Set the forms KeyPreview property to True at design time or during form load you can do
and use the forms KeyDown event handler to block the Alt-F4 key combo as shown below.Code:Me.KeyPreview = True
Code:Private Sub Form1_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.Alt = True And e.KeyCode = Keys.F4 Then
e.Handled = True
End If
End Sub
Hope this helps!Code:Option Explicit
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, _
UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
Cancel = True
End If
End Sub