OnAppClose

Requires: GfaWinx.lg32

Purpose

Instructs the program to execute a differently named event sub – other than the default App_Close - when the program closes.

Syntax

OnAppClose ProcAddr(procname)

procname: the name of the Procedure

Description

Normally an application doesn’t need OnAppClose. By default, the compiler inserts code to execute the sub named App_Close which is invoked when the program is closing. Only when a program wants a different name for App_Close it must use OnAppClose to install a new call back event sub with a new name.

Example

$Library "gfawinx"

$Library "UpdateRT"

UpdateRuntime      ' Patches GfaWin23.Ocx

OnAppClose ProcAddr(App_IsClosing)

OpenW 0, 50, 50, _X / 2, _Y / 2

Do

Sleep

Until Me Is Nothing

 

Sub App_IsClosing() ' new name, executed when app closes

MsgBox "Free resources"

CloseW 0      ' if not terminated normally

EndSub

$Group "Window Events”"

 

Sub Win_0_Click

' Generate some error to abruptly terminate the program.

' Note that App_Close is called.

Error 3

EndSub

Remarks

The call back procedure is executed while GFA-BASIC 32 releases the global variables, just after quitting the application.

See Also

App_Close, AutoFreePtr

{Created by Sjouke Hamstra; Last updated: 07/03/2022 by James Gaite}