ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Options and actions
  • Overview
  • Creating a custom property
  • How to?
  • Example
  • Tip
  • Access rights to a custom property
  • Passing custom properties as a parameter to a WLanguage function or procedure
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
Overview
A custom property is a code element with two events:
  • an event for retrieving the value,
  • an event for assigning the value.
A custom property can be used like a variable or a member (direct value retrieval, assignment with the '=' symbol, etc.). At runtime:
  • Any operation that requires reading the property runs the event for retrieving the value. This event must return a value.
  • Any operation that requires writing the property runs the event for assigning the value. This event must process a parameter.
You can create custom properties on the following elements:
  • control templates.
  • window templates.
  • windows.
  • internal windows.
  • pages.
  • internal pages.
  • page templates.
Creating a custom property

How to?

To create a custom property:
  1. Open the "Project explorer" pane, if necessary (go the "Home" tab, "Environment" group, expand "Panes", select "Panes", and then select "Project explorer").
  2. In the "Project Explorer" pane, display the element on which you want to add a custom property.
  3. Select the desired element. Open the context menu of the element and select "New property".
  4. In the window that appears, enter the name of the property and validate.
  5. The code editor shows the events related to the property:
    • Event "Retrieving the property". This event must contain the "RETURN" (or "RETURN =") keyword to return the value of the property.
    • Event "Assigning the property". This event is used to give a value to the property. This value is passed as parameter. This event must not return a result.
  6. Enter the code of your property.
  7. Enter the code to call the custom property in the desired element.

Example

  1. Creating a custom property for a control template that returns the duration:
    PROCÉDURE PUBLIC duration()
    RETURN DateDifférence(EDT_Start_date, EDT_End_date)
  2. This property of the template will be called in the code of the window:
    Info("The number of days selected is: " + CTPL_Duration.Duration)

Tip

You can override an existing WLanguage property. In this case, the code of the custom property will be run .
You can still access the original property in the code of the custom property, using the following syntax:
MySelf.<Original property>
Example: Assigning a value to the ToolTip property :
PROCEDURE ToolTip(Value)
 
MySelf.ToolTip = "Number of days: " + Value
Access rights to a custom property
Caution: The custom property is read and/or write accessible depending on the associated events that have been defined:
  • If the "Retrieving the property" event is empty, the property cannot be read. If a read operation is performed, a compilation error is displayed in the code editor. An error will occur at runtime as well.
  • If the "Assigning the property" event is empty, it will not be possible to write on the property. If a write operation is performed, a compilation error is displayed in the code editor. An error will occur at runtime as well.
Passing custom properties as a parameter to a WLanguage function or procedure
These are the different cases.
If the parameter is passed by reference (default case) and untyped:
  • the custom property is passed as a parameter.
  • no events associated with the custom property are run during the call.
  • reading the formal parameter triggers the "Retrieving the property" event.
  • writing the formal parameter triggers the "Assigning the property" event.
If the parameter is by passed value (LOCAL) and untyped:
  • the value of the custom property is passed as a parameter.
  • the code for retrieving the value is run during the call.
  • the reading of the formal parameter accesses the value passed during the call and does not run the "Retrieving the property" event.
  • the writing of the formal parameter modifies the value passed during the call and does not run the "Assigning the property" event.
If the parameter is passed by reference (default case) and typed:
  • the custom property is passed as a parameter.
  • the type of the property must be correct. Otherwise, a WLanguage error occurs.
  • no events associated with the property are run during the call.
  • reading the formal parameter triggers the "Retrieving the property" event.
  • writing the formal parameter triggers the "Assigning the property" event.
If the parameter is by passed value (LOCAL) and with specific type:
  • the value of the custom property is passed as a parameter.
  • the "Retrieving the property" event is run during the call.
  • if necessary, the value of the property is converted into the type of the parameter.
  • the reading of the formal parameter accesses the value passed during the call and does not run the "Retrieving the property" event.
  • the writing of the formal parameter modifies the value passed during the call and does not run the "Assigning the property" event.
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/26/2023

Send a report | Local help