Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 14-02-2009
Member
 
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?
Reply With Quote
  #2  
Old 14-02-2009
Member
 
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.
Reply With Quote
  #3  
Old 14-02-2009
Member
 
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
Reply With Quote
  #4  
Old 14-02-2009
Member
 
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!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Disabling ALT + F4 in VB.NET application"
Thread Thread Starter Forum Replies Last Post
Message while opening any application "The application failed to initialize properly(0XC0000142).Click on OK to terminate the application" Griffiths Windows Security 4 07-04-2012 07:19 PM
disabling of HUD in trine 2. Rege's Video Games 6 13-12-2011 06:59 AM
Disabling EV-DO on the LG Voyager Karunashankar Portable Devices 3 13-01-2011 12:25 PM
Disabling sound output for application(s)? Rivulet Technology & Internet 7 25-09-2010 09:15 PM
Disabling unknown application notification in windows 7 Carson Windows Software 5 20-01-2010 07:25 PM


All times are GMT +5.5. The time now is 03:18 AM.