Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case vbFormControlMenu
MsgBox "The user chose the Close command (the ""X"") from the Control menu on the form."
Case vbFormCode
MsgBox "The Unload statement is invoked from code."
Case vbAppWindows
MsgBox "The current Microsoft Windows operating environment session is ending."
Case vbAppTaskManager
MsgBox "The Microsoft Windows Task Manager is closing the application."
Case vbFormMDIForm
MsgBox "An MDI child form is closing because the MDI form is closing."
Case vbFormOwner
MsgBox "A form is closing because its owner is closing."
End Select
End sub
All that said, I would not recommend disabling the closing of a form in this manner, any more than I would recommend reversing the accelerator and brake on a car. There are ways to get what you want without trying to redesign the way the Windows operating system works.
I think the point was that in an application that you suggested, "The Windows norm" would to not offer a control box in possibly a modal window rather than just disabling the close window "X".Some applications are designed to take the user through a serious of steps with forward and back options and possibly an abort option. A partial process may need rolled back. In cases like that I can see not allowing the "X" option. You aren't redesigning Windows, you are designing an application.