ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Supercontrol
  • 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
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
Designing a supercontrol
Overview
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 creator of the supercontrol: person who designs the supercontrol as well as its features.
  • The user of the supercontrol: person who will integrate the supercontrol in the window (or page) and handle 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.
Remark: No custom supercontrol can be added to the supercontrols proposed by WINDEV, WEBDEV and WINDEV Mobile.

Method 1

  1. In the window or page editor, on the "Creation" tab, in the "Containers" group, click "Supercontrol".
  2. Click at the desired location to create the control in the window (or in the page). The supercontrol outline is displayed.
  3. Open the control description (select "Description" in the context menu).
  4. Add the different fields composing the supercontrol ("Add'" button).
Caution: The controls associated with the supercontrol must belong to the supercontrol area defined in the editor. Otherwise, the control will be grayed in the editor and it will not be displayed at runtime.

Method 2

  1. In the window editor or page editor, create the different controls that are included in the supercontrol.
  2. Select the controls (Ctrl key + mouse click or with the lasso).
  3. On the "Modification" tab, in the "Transformations" group, expand "Refactoring and swapping" and select "Create a supercontrol from the selection".
Remark: Controls that are associated with the supercontrol are anchored in respect to the supercontrol (and not in respect to the window or page).

Adding a control into a supercontrol

To add a control into a supercontrol:
  1. Create (if necessary) the control that must be added to the supercontrol.
  2. 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:
  1. Display the supercontrol description.
  2. Click the "Add" button found below the "Local procedures" control. A new procedure is created.
  3. Click the "Code" button to edit the procedure code.
Tip: To create local procedures linked to the supercontrol, you can perform the following operations:
  1. Select your window (or page) and the supercontrol in the "Project explorer" pane.
  2. Click the black arrow found beside the supercontrol name in the project explorer. The local procedures appear.
  3. 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:
    <Supercontrol name>.<Control name>
Remark: EnumControl is used to list the controls that belong to a supercontrol.
Example
The 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.
// Retrieves the current supercontrol
sSuperControl is string
sSuperControl = ExtractString(PopupField(), 1, ".")
dDate is Date     // Today's date by default
// Goes to the previous day
dDate.Day--
// Displays the date of previous day
{sSuperControl+".StartDate"}..Value = dDate
{sSuperControl+".EndDate"}..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.
// Modification code of the edit control
MyParent = MySelf
// Code of selection button
FileName = fSelect(fExtractPath(FileName, fDirectory), ...
fExtractPath(FileName, fFile + fExtension), ...
"Select a file", ...
"All files (*.*)" + TAB + "*.*", "")
MyParent = FileName
Functions and properties specific to the supercontrols

Functions specific to the supercontrols

The following functions are used to manage the characteristics of a supercontrol through programming.
EnumControlReturns the name of the Nth control belonging to the supercontrol.
ResetReinitializes the controls found in a supercontrol.
WinUsefulSizeSpecifies the useful size for the supercontrols with scrollbars.

Properties specific to the supercontrols

The following properties can be used to programmatically handle a supercontrol.
HeightGets and sets the height of the supercontrol.
NameGets the name of the supercontrol.
ValueGets and sets the value of the supercontrol.
WidthGets 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.
See also
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/09/2023

Send a report | Local help