Results 1 to 4 of 4

Thread: Disabling ALT + F4 in VB.NET application

  1. #1
    Join Date
    Feb 2009
    Posts
    10

    Disabling ALT + F4 in VB.NET application

    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?

  2. #2
    Join Date
    Jan 2009
    Posts
    44

    Re: Disabling ALT + F4 in VB.NET application

    In the form's 'Closing' event handler, set 'e.Cancel = True' to stop
    closing the form.

  3. #3
    Join Date
    Jan 2009
    Posts
    18

    Re: Disabling ALT + F4 in VB.NET application

    Set the forms KeyPreview property to True at design time or during form load you can do

    Code:
    Me.KeyPreview = True
    and use the forms KeyDown event handler to block the Alt-F4 key combo as shown below.

    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

  4. #4
    Join Date
    May 2008
    Posts
    115

    Re: Disabling ALT + F4 in VB.NET application

    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
    Hope this helps!

Similar Threads

  1. Replies: 4
    Last Post: 07-04-2012, 07:19 PM
  2. disabling of HUD in trine 2.
    By Rege's in forum Video Games
    Replies: 6
    Last Post: 13-12-2011, 06:59 AM
  3. Disabling EV-DO on the LG Voyager
    By Karunashankar in forum Portable Devices
    Replies: 3
    Last Post: 13-01-2011, 12:25 PM
  4. Disabling sound output for application(s)?
    By Rivulet in forum Technology & Internet
    Replies: 7
    Last Post: 25-09-2010, 09:15 PM
  5. Disabling unknown application notification in windows 7
    By Carson in forum Windows Software
    Replies: 5
    Last Post: 20-01-2010, 07:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,481,832.49120 seconds with 16 queries