Programming a supercontrol
Declaring the global variables of the supercontrol
The supercontrol includes a declaration code of global variables (see Processes associated with the supercontrol
). This code is used to declare all the variables global to the supercontrol. All the types of variables are supported. They can be used in any process 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 description of the supercontrol.
- Click the "Add" button found below the "Local procedures" control. A new procedure is created.
- Click the "Code" button to edit the code of the procedure.
: To create local procedures linked to the supercontrol, you can perform the following operations:
- Select your window (or page) and the supercontrol in the "Project explorer" pane.
- Click the black arrow found beside the name of the supercontrol in the project explorer. The local procedures appear.
- Select "Local procedures". The local procedures displayed are the ones of the supercontrol. You have the ability to add, rename or delete local procedures in the supercontrol.
Accessing the supercontrol and the controls of the supercontrol
When programming the supercontrol, you must access:
- The supercontrol:
the process being independent of the supercontrol name, to find out the name of the supercontrol, we recommend that you use either the MyParent keyword, or 控件上下文菜单, 控件当前所在, ...
- The controls of the supercontrol:
To do so, use the variable of the control in the code. From outside the supercontrol (code of a popup menu of a supercontrol control for example), you must use the following notation:
<Supercontrol name>.<Control name>
is used to enumerate the controls belonging to a supercontrol.
The following example corresponds to the code of an option in a popup 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 控件上下文菜单
. The controls found in the supercontrol are handled by the indirection operators.
// Retrieves the current supercontrol
dDate是日期型// Today's date by default
// Goes to the previous day
// Displays the date of the previous day
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. By default, this value is an empty string. It can be modified by ..值
or by direct assignment.
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
// Code of selection button
"Select a file"，...
"All files (*.*)"+TAB+"*.*"，""）