PC SOFT

WINDEV的在线文档

  • 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 the supercontrol
  • Declaring the functions and procedures linked to the supercontrol
  • Accessing the supercontrol and the controls of the supercontrol
  • Value of a supercontrol
  • Functions and properties specific to the supercontrols
  • Functions specific to the supercontrols
  • Properties specific to the supercontrols
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

Designing a supercontrol

Overview
A supercontrol is an advanced type of control. A supercontrol groups a set of controls for a specific purpose. These controls are independent from the processes of the window or page that hosts 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 is including the supercontrol in his window (or page) and who will be using it by programming. For more details, see: Including a supercontrol in a window or in a page.
18版本和更高版本
WinDevWindows Store apps The supercontrols are now available for the applications in Windows Store apps mode.
18新版本
WinDevWindows Store apps The supercontrols are now available for the applications in Windows Store apps mode.
WinDevWindows Store apps The supercontrols are now available for the applications in Windows Store apps mode.

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: No custom supercontrol can be added to the supercontrols proposed by WinDev, WebDev and WinDev Mobile.

Method 1

  1. In the window editor or in the page editor, click.
  2. Click the position where the control must be created in the window (or in the page). The outline of the supercontrol appears.
  3. Display the description of the control ("Description" from the popup menu).
  4. Add the different controls included in 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 run time.

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. Select "Control .. Refactoring .. Create a supercontrol from the selection".On the "修改" pane, in the "转换" group, expand "重构和切换" and select "Create a supercontrol from the selection".
Note: The controls associated with the supercontrol are anchored in relation to the supercontrol (and not in relation to the window or to the 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 contains 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 content of the supercontrol.

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:
  1. Display the description of the supercontrol.
  2. Click the "Add" button found below the "Local procedures" control. A new procedure is created.
  3. Click the "Code" button to edit the code of the procedure.
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 name of the supercontrol in the project explorer. The local procedures appear.
  3. 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>
Note: 列举控件 is used to enumerate the controls belonging to a supercontrol.

Example

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
sSuperControl字符串型
sSuperControl提取字符串控件上下文菜单(),1"."
dDate日期型// Today's date by default
// Goes to the previous day
dDate..日--
// Displays the date of the previous day
sSuperControl+".StartDate"}..值=dDate
sSuperControl+".EndDate"}..值=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. 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
FileName文件选择器文件提取路径FileName文件.目录),...
文件提取路径FileName文件.名称+文件.扩充),...
"Select a file",...
"All files (*.*)"+TAB+"*.*"""
我的父类=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 by programming.
列举控件Returns the name of the Nth control belonging to the supercontrol.
窗口使用尺寸Specifies the useful size for the supercontrols with scrollbars.

Windows Store apps This function is not available.
重置Re-initializes the controls found in a supercontrol.

Properties specific to the supercontrols

The following properties are used to manage the characteristics of a supercontrol by programming.
高度Used to find out and modify the height of the supercontrol.
宽度Used to find out and modify the width of the supercontrol.
名称Used to find out the name of the supercontrol.
Used to find out and modify the value of the supercontrol.

To find out the entire list of WLanguage properties that can be used with a supercontrol, see Properties associated with a supercontrol.
另见