Events Called During Loading and Unloading

Among many form events, some of events are associated with Loading and Unloading a form. They are called in the order after Load (a form) statement is executed or prior to Unload (a form) statement is evoked.  They are important events for programming with forms.

Loading Events

These are events called in the order during loading a form. For more detailed information, refer to its reference pages:

Unloading Events

These are events called in the order during unloading a form:

Examples

The following examples are used in ATEasy TestExec driver and Profile driver:

 

 

Procedure formTestExec.OnInitialize(): Void Public Compile ! Occurs when the form is created before controls are created.

-------------------------------------------------------------------------

{

! set help file path

form.HelpFile=driver.m_stData.sHelpFile

}

 

 

Procedure formCustomizeAndUsers.OnLoad(): Void Public Compile ! Occurs when a form is loaded after controls are created.

-------------------------------------------------------------------------

{

! init form variables

f_vUserGroups=m_stData.stUsersSettings.vUserGroups

f_vCommands=m_stData.vCommands

f_vLogFilesOptions=m_stData.vLogFilesOptions

 

! only load first page of ATab control, 'tabUsers'

if NOT IsMultiUser()

tabUsers.Pages("pageGroups").Visible=False

tabUsers.Pages("pageUsers").Visible=False

form.Caption="Customize"

LoadPageCommands()

else

LoadPageGroups()

endif

 

! activate first page

tabUsers.ActivatePage(0)

}

 

Procedure ProfileEditorForm.OnResize(): Void Public Compile ! Occurs when a form is first displayed or when the window state of a form changes.

-------------------------------------------------------------------------

...

... ! variable declarations

{

! do nothing if window is not visible (i.e. during form load)

if NOT Form.Visible Then return

 

! remember the normal window state size

if WindowState=aformWindowStateNormal

SaveWindowPosition()

endif

 

! width

lWidth=ScaleWidth()

iAddButtonWidth=lWidth*14/100 ! 14%

iGap=lWidth*1.5/100 ! 1.5%

iTreeViewWidth=(lWidth-iAddButtonWidth-(iGap*4))/2

...

}

 

Procedure formTestExec.OnQueryUnload(pbCancel, enUnloadMode): Void Public Compile ! Occurs before the object closes.

-------------------------------------------------------------------------

pbCancel: Var Bool

enUnloadMode: Val Internal.enumAFormUnloadMode

{

! if running, do not allow to Unload form

if (m_stRunTime.enFlags and ateStart) and (enUnloadMode<>aformUnloadModeFormCode)

pbCancel=TRUE

endif

}

 

Procedure formTestExec.OnUnload(pbCancel): Void Public Compile ! Occurs when a form is about to be removed from the screen.

-------------------------------------------------------------------------

pbCancel: Var Bool

{

SaveWindowPosition()

! maintenance log files

CheckMaintenanceLogFiles(ateMaintenanceUponExit)

! save current setting (window position, last program, options etc...)

SaveCurrentSetting()

m_stRunTime.enFlags=0

m_stRunTime.bWait=False

UnloadLogWindows()

Driver Utility Message Close()

Internal.SetLogOff()

! call procedure ExitApp instead of Exit EndEvents to avoid calling OnEndProgram events again

ExitApp()

}