QueryUnload
How to prevent a form/app from unloading , even if you use the taskmanager? Then try this code... (It works for me ;)
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer) 'To cancel the unload make the cancel = true. Don't do it 'on the vbAppTaskManager one though. Dim ans As String Select Case UnloadMode Case vbFormControlMenu 'Value 0 'This will be called if you select the close from the little icon 'menu on top and left of the form. cancel = False Case vbFormCode 'Value 1 'This will be called if your code requested a unload cancel = False Case vbAppWindows 'Value 2 'vbAppWindows is triggered when you shutdown Windows and your app is still 'running. Added by Jim MacDiarmid cancel = False End Case vbAppTaskManager 'Value 3 'You have to allow the taskmanager to close the program, else you get 'that nasty 'App not responding, close anyway' dialog :< 'The clever way arround it would be to restart your program 'This would be used for a password screen! cancel = False x = Shell(App.Path & "\" & App.EXEName, vbNormalFocus) End Case vbFormMDIForm 'Value 4 'This code is called from the parent form cancel = False End Select End Sub Upload
Original Comments (3)
Recovered from Wayback Machine