Can anyone tell me what is the Xojo equivalent of the VB6 “UnloadMode” parameter of the “Form_QueryUnload” event?
Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
’ your code here
VB6 was able to let you know why your program was being shut down via the UnloadMode parameter:
0 = The user has chosen the Close command from the Control-menu box on the form.
1 = The Unload method has been invoked from code.
2 = The current Windows-environment session is ending.
3 = The Microsoft Windows Task Manager is closing the application.
4 = An MDI child form is closing because the MDI form is closing.
I found it really useful to know why my app was closing. In one particular application I wrote, I needed to know when the computer was shutting down so that I could notify an RS-232 connected device.
I can’t seem to find that type of capability in Xojo running under Linux. Is this information available?
We don’t have access to that information in the Window.Close event.
Edit: However, you can tell whether the app is quitting or not in the Window.CancelClose event. But you don’t know if that’s from a shutdown, or just a quit.
You can find out 0 by using the System.MouseDown in the CancelClose event to see if the mouse is in the upper right corner of the window.
Likewise, if the mouse was not in the red square in the upper right corner, or if the FileQuit menuItem was not used, it means the close was sent by code.
is in App.CancelClose and App.Close events.
could probably be detected with declares, but as it stands, if you quit only in FileQuit and red X, any quit outside of that is system.
I believe you can see that the MDI form is closing in App.CancelClose and App.Close since closing the MDIWindow equates closing the app itself. Although I have not created MDI apps since Windows 3.2
If your app closes only when using the File menu or the red X, you can infer that it quits because the system ordered it to. Now, distinguishing between a systemwide shut down and an app kill under Linux is not available, as far as I know. You would have to use declares, or perhaps MBS plugins.