i am using global function to disable alt+F4 and Esc
Esc is working but alt is not working. pls help
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Escape)
{
MessageBox.Show("sorry you cannot close this form via Esc!!!");
return true;
}
else if (keyData == Keys.Alt)
{
MessageBox.Show("sorry you cannot close this form via Esc!!!");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Manoj BhoirPosted Aug 8, 2015, 10:13 AM
Public Class Form1
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyData = Keys.Alt + Keys.F4 Then
MessageBox.Show("Sorry you cannot close this form via Alt+F4!!!", "Security", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
e.Handled = True
ElseIf e.KeyData = Keys.Escape Then
MessageBox.Show("Sorry you cannot close this form via Escape!!!", "Security", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
e.Handled = True
End If
End Sub
End Class