5. Events : Terminate Event
 
Share this page                  
Terminate Event
The Terminate event is triggered for the frame when the frame is told to terminate, by the Terminate method defined on the GhostExec object, by an ancestor frame that executes a return statement, or by the user closing the window through a window manager's close operation.
Note:  In this last case a “resume” in the on windowclose block would prevent the Terminate.
This event has the following syntax:
on terminate
The following FrameExec attribute can be used in the Terminate event block:
InputFocusField
Specifies the field with the current input focus
Use the CurFrame system variable to access this attribute. For more information, see FrameExec Class (see FrameExec Class).
Usage: This event is defined only for the frame as a whole.
The Terminate event is used to check that frames are cleanly closed. You can use this event to check for and clean up open transactions or to save any changes before closing. However, you cannot use the Terminate event block to keep the frame open. When the Terminate event block completes, the frame and its window are closed. Because executing a resume statement terminates an event block, in the case of a Terminate event block the resume statement also terminates the frame and the window.
The following Terminate event block demonstrates how to save any changes on the form before closing the frame:
on terminate =
begin
if CurFrame.ConfirmPopup(messagetext = 'Save
changes?') = PU_OK then
          /* save changes to database */
endif;
end
If any frame in the application executes an exit statement, OpenROAD sends a Terminate event to all open frames in the application (including the frame issuing the exit statement). Additionally, if a user attempts to close a window using the standard window manager functions, both the Terminate event and a WindowClose event are triggered. In such cases, the WindowClose event is executed first. Thus, if you execute a resume statement in the WindowClose event block, the Terminate event is not processed. For more information about this event, see WindowClose Event (see WindowClose Event).
More information:
InputFocusField Attribute (see page InputFocusField Attribute)