On Jul 23, 11:08 am, Udo Nesshoever <Brucklyn...@googlemail.com>
wrote:
=== original message ===
from: Cor Ligthert[MVP]
date: 23.07.2008 09:46
Don't use the cancel on the close. It makes your users insecure. Disable
the close button.
And how would that prevent closing the app with e.g. Alt+F4?
Cheers,
Udo
If you disable close box using the code in that thread or here;
http://groups.google.com/group/micro...b18cca5e507edb
...users won't be able to close the application using ALT+F4.
However if you want to disable ALT+F4 without disabling close box (red
one), you can implement in that way:
First set form's KeyPreview property to True, then use form's KeyDown
Event:
'----Code Begins-----
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyData = Keys.Alt + Keys.F4 Then
'Notify user
MessageBox.Show("Sorry, You can't exit")
'Stay alive
e.Handled = True
End If
End Sub
'---Code Ends-----
..and remember, with that way, users will be allowed to quit using X
(close) button, but not with ALT+F4 combination if you're looking only
for this.
Hope this helps,
Onur Güzel