Questions

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

+
0 Votes
Locked

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

samohod26
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.
  • +
    0 Votes
    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.

    +
    0 Votes
    starwin_ms

    <script type="text/javascript">
    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;
    }
    }
    </script>

    +
    0 Votes
    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

  • +
    0 Votes
    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.

    +
    0 Votes
    starwin_ms

    <script type="text/javascript">
    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;
    }
    }
    </script>

    +
    0 Votes
    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