Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Program termination

I have a menu entry that Ends my program. Works as expected. However, if I terminate the program by clicking on the window close icon (little red X in upper right corner of window), the GUI goes away but task manager shows that it is still loaded in memory and running. Is there a way to catch the Window Close event? What am I missing?Running XP Pro SP2 & VB6.
[361 byte] By [ksquared] at [2007-11-11 10:19:46]
# 1 Re: Program termination
form_unload()
or
form_queryunload()
Amahdy at 2007-11-11 17:22:46 >
# 2 Re: Program termination
Ok - now I'm :confused: . If form_unload() can be used to capture the click of the Close window event, I just don't see how. I'm talking about the red X as shown here picture link (http://members.cox.net/krkaplan/x.gif) . I don't know how to detect that event. It seems like it is outside of the VB environment. No?
ksquared at 2007-11-11 17:23:46 >
# 3 Re: Program termination
When the user clicks the red X to close a form, the form's Unload event fires. From the Form_Unload event procedure, you can call your Exit menu code (I recommend moving the code to a Sub procedure and calling it from both the Exit menu's click event and the Form_Unload event).
Phil Weber at 2007-11-11 17:24:52 >