Is there a Delphi event that is guaranteed to be triggered when the application terminates, but before any forms are destroyed?

I am using Delphi 6 Pro. I need an event that will fire when my application is finally closed, but before any forms are destroyed. I was thinking of catching WM_QUIT messages in the main form of WndProc (), but this did not work because Forms started to kill before I saw the WM_QUIT message. I was wondering if there is a standard Delphi event that I can use to execute code at this event point breakpoint? I cannot use the FormClose () form event, since it is not guaranteed, and the FormDestroy () event is too late. Any ideas?

+7
source share
2 answers

In the WndProc() method, you will not see the WM_QUIT WM_QUIT , since WM_QUIT is a signal for message cycles to stop executing and as such are usually not sent to the window procedure.

There is no specific event for what you ask. However, you can open the .dpr project file and put in any code you need after calling Application.Run . The message loop is no longer running, but the Application and MainForm are not yet freed.

+14
source

The best way to do this (and I have been looking at this for many years over the years) is to link the procedure using the AddTerminateProc () procedure in SysUtils.pas. This works every time, and I have been using it for many years (unless you kill the process through the task manager).

+7
source

All Articles