Exit EXE Close Button Enhancement [SOLVED]

Is it possible, when a user clicks on the red X in the upper corner of the main window to close the EXE, that it can also process the “procedure MacroExit” or another user specified HE script that will process a HE script before the EXE exits with ExitPublication?

The exit script works great but gets skipped if the user closes the EXE by clicking on the red X button.

Thanks,

Try this event in UserMain:

procedure OnCloseWindow(WindowName: String);
begin
// When a window is closed by the user.
end;

This worked great. Put in a if conditional test for the main window and a blank else statement for other windows, if ever needed at a later date.

I had seen this before but I didn’t think it would work for the main window, but it did.

Thanks,