- Creating a control template
- Creating a control template from the window editor
- Creating a control template from the page editor
- Creating a control template from existing controls
- Special cases
- Testing a control template
- Using a control template
- Renaming a control template
A control template is a set of controls that can be re-used in several windows or pages.
- WINDEV and WINDEV Mobile allow you to create control templates that can be used in the windows.
- WEBDEV allows you to create control templates that can be used in pages.
A control template can be edited or modified; when a template is modified, these modifications can be applied to all the windows or pages that use this template.
The control templates are used to:
- group a set of controls for a specific purpose.
- make the controls independent of the window that is hosting them.
Furthermore, the control templates are saved in a ".WDT" file that can be easily transferred from one project to another.
Benefit compared to supercontrols: The modifications made to the control templates can be automatically applied to all the windows (or pages) that use the control template.
Benefits compared to internal windows or pages: The control templates are directly inserted, visible and modifiable in the window or in the page. They can be directly overridden in the window or page that uses the control template.
Creating a control template
Creating a control template from the page editor
To create a control template from the page editor:
- From the page editor, create a new control template:
- Click in the quick access buttons.
- The creation window appears: click "Page" then "Control template". You can:
- Create a blank control template,
- If your project is already using the control templates, create a control template based on another control template of the project. In this case, you will have the ability to perform cascading updates of control templates.
- Create all the necessary controls. These controls will be included in all the windows or pages that use the control template.
Remark: The control templates can be nested. A control template can use another control template.
- If necessary:
- Enter the processes associated with the controls. These processes will be automatically imported into the window or page that uses the control template.
- Anchor the controls in the template. These anchors will be automatically used in the window or page that uses the control template.
- Adjust the size of the template to the controls present in the template ("Resize" in the context menu).
- Give your template a name ("General" tab of the description window).
Remark: If you are using the code style, the name of the control template is prefixed by "TPLC_".
- Save your control template (). The control template is available and it can be used in a "Control template" control. The created file is in ".WDT" format.
: Templates do not support style overrides.
Creating a control template from existing controls
To create a control template from existing controls:
- Select the controls that must be included in the control template.
- On the "Modification" tab, in the "Transformations" group, expand "Refactoring and swapping" and select "Create a control template from the selection".
- You can also select "Refactoring .. Create a control template from the selection" in the context menu of the selection.
- You have the ability to create a template of a control template, which means a a control template based on another control template.
- The context menus are available in the control templates:
- If the window includes context menus, the context menus of the control template must have different names.
- The context menus of the control template are added to the context menus of the window.
- If there are two identical control templates with context menus in a window, the override of the context menu of the control template applies to both control templates.
- If several control templates found in a window have the same source, updating a control template triggers the update of all the control templates that use the same source in the window.
Testing a control template
To run the test of a control template:
- Open the control template in the editor.
- Click the "Go" button ("Run the window test" or "Run the page test" icon).
To use a control template:
- Open the window or the page in which the control template must be included.
- Create a Control Template control: on the "Creation" tab, in the "Containers" group, click "Control template".
- Select the control template that will be included in the window or in the page.
Caution: The control template is associated once and for all to the "Control Template" control. To change the association, you must delete the "Control Template" control and re-create it.
- Validate and position the control in the window or in the page.
: A control template created with WINDEV (for a window) cannot be used in a page and a control template created in WEBDEV (in a page) cannot be used in a window.
Renaming a control template
If a control template is renamed, the link with the elements that use this template is lost.
This link can be restored via the window that lists the templates: on the "Window" tab, in the "Templates" group, expand "Templates" and select "List of templates used".
Training (WEBDEV): WW_Auto_Zoom
Training (WEBDEV): WW_RSS_Stream
This page is also available for…