Modifies the style of a control dynamically.
// Modify the style of EDT_Edit1 control
<Result> = ChangeStyle(<Control used> , <Style to apply> [, <Skin template to apply>])
- True if the style was changed,
- False if an error occurred.
<Control used>: Control name
Name of control whose style must be modified.
<Style to apply>: Character string
Name of style defined in edit. This style must be applicable to the specified type of control.
<Skin template to apply>: Optional character string
Name of the skin template to be applied (name and path of the "*.WDY" file, if necessary). The extension must not be specified.
If this parameter corresponds to an empty string (""):
- the skin template defined in the window editor will be applied by default. Caution: If a skin template has been dynamically set with ChangeSkinTemplate, it will take precedence.
- the windows already opened will keep the current skin template.
If this parameter is not specified, the skin template file (*.WDY) associated with the current project will be used.
The description of a skin template is stored in a ".WDY" file. The ".WDY" files corresponding to the skin templates proposed by WINDEV are provided with WINDEV.
To apply a custom style or a project style, the following syntax must be used:
ChangeStyle(<Control>, <CustomStyle>, <ProjectName.wdy>)
Except if it was renamed, the .WDY containing the project styles is named like the project itself.
- When creating a skin template, the ".WDY" file is automatically created.
- To generate the ".WDY" file of an existing skin template:
- Open the "<NameOfSkinTemplate>.STY" file in WINDEV: on the "Home" tab, in the "General" group, click "Open".
- Save this file: on the "Home" tab, in the "General" group, click "Save".
Deploying an application
When creating the setup program of your application, the following elements must be added into the list of elements to install:
- the ".WDY" file of the project.
- the ".WDY" file corresponding to the new skin template applied by ChangeStyle.
- the image files used by the new skin template applied by ChangeStyle. Caution: the images used by the different skin templates must have different names otherwise these images will not be modified.
Remark: To add one or more elements to the list of project elements:
- On the "Project" tab, in the "Project" group, expand "List of elements".
- Select "List of project elements".
- Click the "Add" button.
- Select the files to add and validate.
- You also have the ability to copy the style of a control to another one via Style.
- When changing style, the positioning of captions is not modified. Indeed, changing the positioning of captions could trigger modifications regarding the size of the control. The control could come into conflict with other controls.
- Button controls:
- If the style includes an image, this image overwrites the initial image of the button.
- If the style includes no image, the initial image of the button is kept.