OnCloseWindow not working in 4.7

Referencing: Exit EXE Close Button Enhancement [SOLVED]

Has anything changed with the OnCloseWindow with 4.7?

This was working prior to 4.7 and 4.7.1 but it seems like it goes into a loop and the only way to exit is terminate the process in the task manager.


Edited: Wanted to add that a messagebox was inserted and it fires off repeatedly and the ExitPublication never allows the program to exit like it did before.

We have introduced a new event OnWindowCloseQuery but it is not yet documented.

How do I ask users if they are sure they want to close the main window?

Use HEScript scripting and a dedicated event in UserMain (OnWindowCloseQuery):

For instance, use this HEScript function in your UserMain script.

function OnWindowCloseQuery (WindowName: String): Boolean;
 Result := True;
 if MessageBox("Do you really want to close this window?", 
 "Confirmation", MB_YESNO+MB_ICONWARNING) = IDNO then Result := False;

Don’t use OnCloseWindow to prevent the program from closing the window. When this event is fired, the program is going to exit.

Actually, I was using it when the user clicks on the red X of the main window only. This allowed me to run a routine before executing the program with ExitPublication.

It probably wouldn’t hurt to have them confirm to exit the program. A variable could be set to show or hide the confimation message.

In version 4.7, the way the program is looping, It’s like the OnWindowClose keeps firing. The message box is above the ExitPublication but never executes and exits, as it did before. You get into a loop of constantly seeing the message box keep coming up. In the routine, there are no loops, just a if else and everything works as expected except exiting the program. At that point, the only to exit is to abort it in the Task Manager.

I will give the OnWindowCloseQuery and see if that works and will let you know.