Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am creating an HTA to use as a utility. Part of what it needs to do is output its activity to a log file. If someone were to close the window using the X in the upper right corner, is there a way to code it so the log file is closed first? I know you can do this with Windows Apps created with Visual Studio but I'm not sure about this.

Thanks,

Rob
Posted

You can do it by handling the event window.onunload. Please see, for example: http://www.thecodingforums.com/threads/catching-window-close-event-in-hta.931828[^].

—SA
 
Share this answer
 
I ran a test and this should work for me:

Sub window_onbeforeunload

MsgBox "Close log files - Cleanup memory"

End Sub

Of course you would use code that actually closes a log file or any other tasks that need to be done before the app closes. This is merely to demonstrate how it works.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900