Click to See Complete Forum and Search --> : How I can remove ALT+F4 from a dialog box?..


abkareem
July 22nd, 1999, 10:05 AM
Dear All,

How I can remove ALT+F4 key from a dialog box?.. I dont want to quit the dialog box when user press ALT+F4 key?.....

PL help me,....

Regards,
Kareem.

Lothar Haensler
July 22nd, 1999, 11:43 AM
you can trap the Form_QueryUnload event and check for the UnloadMode argument.
If you don't want the user to be able to end your program just set the Cancel argument to false.

abkareem
July 22nd, 1999, 12:06 PM
Hi,,

Thanks for your reply. But It does not work properly. After I added Form_QueryUnload() function and set Cancel to false, user can quit the dialog by pressing ALT + F4. You pl check .... let me know that ...

Regards,
Kareem.

Ravi Kiran
July 23rd, 1999, 12:40 AM
Set it to True or 1.
use Cancel = 1 . Cancel is defined as integer in QueryUnload and Unload events!!

But this code will also stop the unload from 'X' of the Form Control menu!!

private Sub Form_QueryUnload(Cancel as Integer, UnloadMode as Integer)
If UnloadMode = 0 then Cancel = 1
Debug.print UnloadMode
End Sub

Lothar Haensler
July 23rd, 1999, 01:36 AM
you need to set cancel to True!

private Sub Form_QueryUnload(Cancel as Integer, UnloadMode as Integer)
Cancel = true
End Sub



now you won't be able to close the form

Cimperiali
September 18th, 2001, 09:49 AM
;-)

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

MKSa
September 18th, 2001, 11:01 AM
Make sure that the form KeyPreview is set to True then try the following code:
option Explicit
Dim CancelAltF4 as Boolean

private Sub Form_KeyDown(KeyCode as Integer, Shift as Integer)
CancelAltF4 = false
If KeyCode = vbKeyF4 then
If Shift And 4 = 4 then
MsgBox "ctrlv"
CancelAltF4 = true
End If
End If
End Sub
private Sub Form_QueryUnload(Cancel as Integer, UnloadMode as Integer)
If CancelAltF4 then
Cancel = true
CancelAltF4 = false
End If
End Sub

Cimperiali
September 18th, 2001, 11:03 AM
Have a look at date this question was first posted....
;-)

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater