WINDEV, WEBDEV and WINDEV Mobile handle the following events by default (order of appearance in the code editor):
|Initializing||Run when the application is started. Here is the order in which the events are run when starting an application (also when running a test):|
(*) The initialization event of a component is run only when the component uses the same runtime context as the project. For more details on the component generation options, see Creating and generating an external component.
- Initialization of the components "loaded when starting the application".
- Initialization of sub-components(*).
- Initialization of component classes.
- Initialization of the sets of procedures of the component.
- Initialization of the component project(*).
- Initialization of classes.
- Initialization of sets of procedures.
- Initialization of the project.
- Initialization of the first project window or of the element whose test is run.
If Use is run, the project initialization event is interrupted (all the lines of code after Use will not be run).
Some examples of how to use this event:
|Used if the site is run with cached sessions. |
To manage pre-launched sessions, two events are associated with the project:
- "Initializing the project", run before the request reaches the WEBDEV application server. This code is run when starting the pre-launched session.
- "Initializing the project after connection to the site", run when the WEBDEV application server processes the request.
Caution: Some WLanguage functions must not be used in the event "Initializing the project". They must be moved to the event "Initializing the project after connection to the site".
|Closing||Run when the closing application (when the last window of the application is closed for example).|
Here is the order in which the events for closing the project are run:
This event will not be run:
- Closing the project.
- Event for ending the sets of procedures.
- Event for ending the classes.
- Closing the components (closing the component project, then its sets of procedures, then its classes, then its sub-components).
- When EndProgram is run and the "Closing code" parameter is not specified or is set to "False".
- When AppControl is run and the "Run project closing code" parameter is not specified or is set to "False".
Closing the session
|Run in the following cases if the application is currently used:|
In these cases, only this event will be run. The events for closing the project as well as the events for ending the classes and the sets of procedures will not be run.
- When closing the current user session.
- When stopping the system of the current computer.
- When restarting the current computer.
Remark: Depending on the operating system of the current computer, the operating system may try to abruptly stop the application after a while.
Some examples of how to use this event:
- Freeing the libraries loaded in memory by FreeDLL (if libraries have been loaded in memory).
- Freeing classes, OLE Automation objects and dynamic arrays (Free keyword).
- Canceling the current transactions (HTransactionCancel).
- Closing the HFSQL files (HClose).
- Sending information messages to other computers (SendMessage).
- Running the event for closing the project with EndProgram with "Closing code" set to "True".
To enable this event, go to the "Automatic tests" pane, "Tests" group, click the dialog box launcher (
) and select "Enable automatic test code of the project".
To disable this event, go to the "Automatic tests" pane, "Tests" group, click the dialog box launcher (
) and select "Disable automatic test code of the project".
In the case of an automatic test, this event is run before the project initialization code. This code us used to process some special cases where the automatic test may be locked: opening a window in the initialization code of the project (configuration window, license window, custom login window, ...).
The code for automatic project test allows you to use EmulateWindow
to validate the window.
Move to the background
|Run when the application is moved to the background. This event is used, for example, to save the data.|
Remark: This event is run AFTER the optional window event "Move application to the background".
Move to the foreground
|Run when the application is re-enabled and when it is moved to the foreground. This event is used, for example, to refresh the displayed data.|
- This event is not run when the application starts.
- This event is run BEFORE the optional window event "Move application to the foreground".
Application of light/dark theme
|Run in the following cases: |
- When the application starts (after the "Initializing" event of the project).
- When the theme is changed by programming with ChangeTheme only if the withCodeExecution constant has been specified.
- When the system automatically changes the theme: modification of system settings, changing the day/night time, activating/deactivating the battery saver, etc.