ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Window template
  • Overview
  • Principle of inheritance and override
  • Overriding windows
  • Overriding window properties
  • Overriding the code of the windows
  • Overriding controls
  • Overriding the control style (UI override)
  • Overriding the control code (code override)
  • Remarks
  • Managing overridden properties of a control
  • Finding out the overridden properties:
  • Overriding local procedures
  • Overriding the code of a local procedure
  • Limitations
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Window templates and inheritance
Overview

Principle of inheritance and override

When a window template is applied to a window, all the controls and code found in the template are "copied" into the window. This is the concept of inheritance.
The template controls are visible in the window, in the window editor. A yellow square is found in the upper-left corner of each control. By default, the controls found in the template cannot be modified.
The template code is visible in the code editor, in the different events of the window or its controls. This WLanguage code can be easily identified:
  • the events associated with the template are followed by "(<Template name> template)" (for example: "Click the Validate button (MyTemplate template)").
  • the background of the events is grayed because the code cannot be modified.
For a template of templates, the inheritance is performed on several levels.
You can override controls, local procedures and the code of the template. Overriding controls, local procedures and the code enables you to modify, for a given window, the code, the local procedures and/or the controls of the template.
Overriding windows

Overriding window properties

Overriding the properties of the template windows consists in modifying the characteristics of the window that uses the template (the characteristics displayed in the description window for example).
As soon as one of the characteristics of the window that uses the template is modified (the width of the window for example), this property is overridden.
Remark: The template window can use a skin template with "Layout" controls (the ActiveVista template for example). These controls are used to display the title of the window, the system buttons, ... These layout controls are considered as being properties of the window.

Overriding the code of the windows

To override the code of template windows:
  1. Open the events of the window (select "Code" in the context menu).
  2. If an event exists in the template window, this event appears twice in the window that uses the template. Indeed, the following elements are displayed:
    • the event from the template. This event appears in gray and its caption is followed by "(<Template name> template)".
    • the window event.
  3. The code typed in the window event will be run as follows:
    • the "Global declarations" event is merged between the template and the window that uses the template. Therefore, variables with the same name must not be used in this event.
    • for all the events (except the window closing event): the events of templates applied to the window are run in the order in which they were included, then the event corresponding to the window is run.
    • for the window closing event: the window closing event is run, then the events of templates applied to the window are run in the reverse order in which they were included.
Overriding controls

Overriding the control style (UI override)

To override the interface of a template control (a button for example):
  1. Display the popup menu of a template button found in the window.
  2. Select "Override control".
  3. The yellow square was replaced with a blue square, indicating that this control can be overridden.
    Control not overridenControl overridden
  4. You can now modify all the aspects of the button interface: dimensions, position, style, ...
    Control modified by override

Overriding the control code (code override)

To override the code of a template control (code of a button for example):
  1. Display the popup menu of a template button found in the window.
  2. Select "Override control".
  3. The yellow square was replaced with a blue square, indicating that this control can be overridden.
  4. Display the button code ("Code" in the context menu).
  5. Two sections of click code are found:
    Code override
    • the click code issued from the template.
    • the click code of the window. A function was automatically added: ExecuteAncestor. This procedure runs the click code of template.
  6. Add the code of the button specific to the current window, before and/or after the procedure for calling the template code. You have the ability to delete ExecuteAncestor if you do not want the template code to be run.
    ExecuteAncestor

Remarks

  • An overridden button cannot be deleted from a template.
  • Overriding a table also overrides the columns. You have the ability to add columns into an inherited table.
  • You have the ability to add panes to a template tab and to include template controls in this pane.
  • Style override is not available.
Managing overridden properties of a control

Finding out the overridden properties:

To find out the control properties that have been overridden:
  1. Open the popup menu of control.
  2. Select "Overridden properties".
  3. The override management window opens.
This window allows you to delete overridden properties. To do so, select the requested property and delete it.
To entirely delete the overridden operations performed on a control, simply select "Full override".
Overriding local procedures

Overriding the code of a local procedure

To override the code of a local procedure from the "Project explorer" pane:
  1. Select the element associated with the local procedure (window, page, report, etc.).
  2. Expand the element options and select "Local procedures".
  3. Select the procedure to override.
  4. Open the context menu and select "Override code of local procedure".
  5. Two sections of click code are found:
    Overriding a local procedure
    • the code of the procedure issued from the template.
    • the code of the new procedure. A function was automatically added: ExecuteAncestor. This function runs the code of the template procedure.
  6. Add the code of the new procedure specific to the current element, before and/or after the procedure for calling the template code. You have the ability to delete ExecuteAncestor if you do not want the template code to be run.
    Caution: the prototype of the overridden procedure must be identical to the prototype of the new procedure.
Limitations
  • No embedded query can be used in a template control. The execution of the window that uses the template will trigger an error.
  • No menu can be used in a template: the menu will not be copied into the window that uses the template.
  • Style override is not available.
See also
Minimum version required
  • Version 11
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/16/2023

Send a report | Local help