ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / Control functions
  • Declaring a Control variable
  • Assigning a Control variable
  • Using a Control variable in a procedure
  • Optimizing the processes with indirection
  • Properties associated with a Control variable
  • Functions that handle a Control variable
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
Control (Type of variable)
In french: Champ
The Control type is used to define the characteristics of a control. This control can be dynamically created by ControlCreate or it can be a control found in a window or in a report.
AndroidAndroid Widget Java ControlCreate is not available.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
WINDEV
// Dynamically create a control in a window
c is Control
c <- ControlCreate("BUTTON_1", typBouton, 30, 40, 140, 20) // Caution, not '='
 
c.Caption = "Click here"
 
c.Process[trtClick] = myProcedure
Remarks

Declaring a Control variable

The following syntax is used to declare a Control variable:
<Variable Name> is Control

Assigning a Control variable

A Control variable can be used to handle:
  • a control found in a window or in a report.
  • WINDEV a control created by ControlCreate.
The assignment of a Control variable must be performed by the '<-' operator.
Examples:
// Assignment with an existing control
c is Control
c <- EDT_Edit1
// Assignment by using the indirection
// The variable references the EDT_EDIT2 control
c <- {"EDT_EDIT2"}
WINDEV
// Assignment with a control created by ControlCreate
c is Control
c <- ControlCreate("BUTTON_1", typButton, 30, 40, 140, 20)
Caution: The '=' operator must not be used to assign a Control variable. This operator is used to transfer the value of a control into another control of the same type. For example:
// Assignment with an existing control
c is Control
c <- EDT_Edit1
 
 
// Modify the value
c = EDT_Edit3 // Equivalent code: EDT_Edit1.Value = EDT_Edit3.Value
 
c = "Text" // Equivalent code: EDT_Edit1.Value = "Text"
Remark: To know if a value has been assigned to the Control variable, use the Type property on the variable.

Using a Control variable in a procedure

The Control type can be a parameter of a procedure. You can write for example:
  • the code of the procedure:
    PROCEDURE MyProcedure(C is Control)
    C = "It is " + TimeSys()
  • the call to the procedure:
    MyProcedure(EDT_Edit1)

Optimizing the processes with indirection

The Control type can be used to optimize the processes that use the indirections. You can write for example:
C is Control <-{s, indControl}
C.Width = 10
C.Height = 20
rather than the following code:
{s, indControl}..Width = 10
{s, indControl}..Height = 20

Properties associated with a Control variable

The Control type is used to handle all types of controls found in a window or in a report. The available properties depend on the type of control used.
Therefore, if a Control variable is used to handle an edit control, all the WLanguage properties available for the edit control will be usable on the Control variable.
To get the properties of a control, see the control help page: the "See Also" link is used to access all the control properties. For more details, see Window controls.

Functions that handle a Control variable

All the WLanguage functions that handle the controls can be used on a Control variable. However, only the WLanguage functions corresponding to the type of control used will be available.
Therefore, the TableXXX functions can be used on a Control variable that handles a Table control.
Minimum version required
  • Version 19
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 08/31/2023

Send a report | Local help