|
-
Sep 9th, 2000, 11:05 AM
#1
Thread Starter
Hyperactive Member
The other day we all learned how to disable the close button
with GetSystemMenu and RemoveMenu. They will allow you to
disable (grey-out) the shutdown X in the control box. But
this will still leave ALT+F4 as a means to shut down your app.
Is there any way to intercept this keypress sequence to force
the user into using a command button to quit the app? Or a
way to disable ALT+F4 from closing your app?
-
Sep 9th, 2000, 11:32 AM
#2
There's a couple of things you can do. The first is to set the ControlBox property of the form to False but this will also remove the system menu completly.
The second thing to do is to add code to the QueryUnload event.
Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
'the user is trying to close the window by
'either keying ALT+F4 or by using the "X" button
Cancel = True
End If
End Sub
Have a look in MSDN library for other values you can check for in the QueryUnload event.
Good luck!
-
Sep 9th, 2000, 07:31 PM
#3
Thread Starter
Hyperactive Member
Thanks,
The second method is the one I was looking for. And
the MSDN library for this event has other useful tidbits that may come in handy.
-
Apr 12th, 2001, 09:23 AM
#4
altF4 disable
Thank you Joacim Andersson. Your answer worked immediately and solved a big problem for us!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|