Question Locked

how to disable the alt+F4 key for the windows form

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

i want to disable the form option alt+F4 key due to which it is closing my form,the form is login form in my application.

I need the solution for this problem.

4 replies

by tony hopkinson

Don't know what language you are using

if (myLoginForm.ShowModal == mrOK)
{ // check user name and password
// if not valid exit the application and}
else
// exit the application;

Otherwise the would have to login before they could could log out and exit.

by starwin_ms

var altDown=0;
if (typeof window.event != 'undefined'){
document.onkeydown = function(){
window.status=event.keyCode
if(event.keyCode == 18)altDown=1;
alert();
if(event.keyCode == 115&&altDown==1)
event.returnValue=false;
altDown = 0;
}
}

by suscriber07.siva

The following code will disable the functionality of Alt+F4 key in ur Form

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

This discussion is closed to new replies.