|
|
|
|
|
- Overview
- Creating a supercontrol in the editor
- Method 1
- Method 2
- Adding a control into a supercontrol
- Supercontrols and scrollbars
- Programming a supercontrol
- Declaring the global variables of supercontrol
- Declaring the functions and procedures linked to the supercontrol
- Accessing the supercontrol and the controls of supercontrol
- Value of a supercontrol
- Functions and properties specific to the supercontrols
- Functions specific to the supercontrols
- Properties specific to the supercontrols
A supercontrol is an advanced type of control. A supercontrol groups a set of controls for a specific purpose. The controls are independent of the processes carried out in the window or page that contains them. Two types of users are allowed to handle a supercontrol: - The supercontrol creator: the person who designs the supercontrol and the functionality it is to provide.
- The supercontrol user: the person who will integrate the supercontrol into his or her window (or page) and manipulate it programmatically. For more details, see: Including a supercontrol in a window or in a page.
Creating a supercontrol in the editor Two methods can be used to create a supercontrol: - Creating an empty supercontrol and creating the controls included in the supercontrol.
- Creating a supercontrol from existing controls.
Note: It is not possible to add personal supercontrols to the default supercontrols proposed by WINDEV, WEBDEV and WINDEV Mobile. Method 1 - In the window or page editor, on the "Creation" tab, in the "Containers" group, click "Supercontrol".
- Click at the desired location to create the control in the window (or in the page). The supercontrol outline is displayed.
- Open the control description (select "Description" in the context menu).
- Add the different fields composing the supercontrol ("Add'" button).
Caution: Fields associated with the supercontrol must belong to the supercontrol zone defined in the editor.. Otherwise, the control will be grayed in the editor and it will not be displayed at runtime. Method 2 - In the window editor or page editor, create the different controls that are included in the supercontrol.
- Select the controls (Ctrl key + mouse click or with the lasso).
- On the "Modification" tab, in the "Transformations" group, expand "Refactoring and swapping" and select "Create a supercontrol from the selection".
Note: Fields associated with the supercontrol are anchored to the supercontrol (and not to the window or page). Adding a control into a supercontrol To add a control into a supercontrol: - Create (if necessary) the control that must be added to the supercontrol.
- Position the control in the supercontrol area. The supercontrol area is bordered by a green line.
The control is automatically added to the supercontrol.
Supercontrols and scrollbars A supercontrol is made off a displayed area (black handles) and a displayable area (red handles). To modify one of these two areas, move the handles while keeping the Shift key down. If the displayed area is smaller than the displayable area, scrollbars are automatically displayed. This is used to create supercontrols with scrollbars allowing you to scroll the supercontrol content.
Programming a supercontrol Declaring the global variables of supercontrol The supercontrol includes a declaration code of the global variables (see Events associated with the supercontrol). This code is used to declare all variables global to the supercontrol. All the types of variables are supported. They can be used in any event associated with the supercontrol or with one of the controls included in the supercontrol. Declaring the functions and procedures linked to the supercontrol To create a procedure local to the supercontrol: - Display the supercontrol description.
- Click the "Add" button found below the "Local procedures" control. A new procedure is created.
- Click the "Code" button to edit the procedure code.
Tip: To create local procedures linked to the supercontrol, you can perform the following manipulations: - Select your window (or page) and the supercontrol in the "Project explorer" pane.
- Click the black arrow found beside the supercontrol name in the project explorer. The local procedures appear.
- Select "Local procedures". The local procedures displayed are the ones of supercontrol. You have the ability to add, rename or delete local procedures in the supercontrol.
Accessing the supercontrol and the controls of supercontrol When programming the supercontrol, you must access: - The supercontrol:
As the process must be independent of the name of the supercontrol, to get the name of the supercontrol, it is recommended to use either the MyParent keyword or functions such as ControlContextMenu, ControlCurrent, etc. - The controls of supercontrol:
To do so, use the control variable in the code. From outside the supercontrol (code of context menu of supercontrol control for example), you must use the following notation:
<Nom du superchamp>.<Nom du champ> Remark: The EnumControl function can be used to enumerate fields belonging to a supercontrol. ExampleThe following example corresponds to the code of an option in a context menu. This menu is associated with a control of a supercontrol and it is used to modify the "StartDate" and "EndDate" controls of the supercontrol. In this code, the name of the current supercontrol is returned by ControlContextMenu. The controls found in the supercontrol are handled by the indirection operators.
sSuperChamp is string
sSuperChamp = ExtractString(ControlContextMenu(), 1, ".")
dDate is Date
dDate..Day--
{sSuperChamp+".DateDébut"}..Value = dDate
{sSuperChamp+".DateFin"}..Value = dDate
Value of a supercontrol A supercontrol includes several controls and it can return a value. This value can correspond to the value of a control found in the supercontrol or to any other information. This value is an empty string by default. You can change it using the Value property or by directly assigning a value to it. Example: A supercontrol is used to select a file.. It contains an edit control and a button used to opens the file picker. The value of the supercontrol must correspond to the name of the selected file. To do so, the value of the supercontrol must be assigned: - in the modification code of the edit control,
- in the click code of the selection button.In this code, the MyParent keyword is used to designate the supercontrol in the code of one of its own controls.
NomFichier = fSelect(fExtractPath(NomFichier, fDirectory), ...
fExtractPath(NomFichier, fFile + fExtension), ...
"Sélectionner un fichier", ...
"Tous les fichiers (*.*)" + TAB + "*.*", "")
MyParent = NomFichier
Functions and properties specific to the supercontrols Functions specific to the supercontrols The following functions are specific to the programmed management of supercontrol characteristics. | | EnumControl | Returns the name of the Nth control belonging to the supercontrol. | Reset | Reinitializes the controls found in a supercontrol. | WinUsefulSize | Specifies the useful size for the supercontrols with scrollbars. |
Properties specific to the supercontrols The following properties can be used to programmatically handle a supercontrol. | | Height | Gets and sets the height of the supercontrol. | Name | Gets the name of the supercontrol. | Value | Gets and sets the value of the supercontrol. | Width | Gets and sets the width of the supercontrol. |
For a complete list of WLanguage properties that can be used with a supercontrol, see Properties associated with a supercontrol.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|