ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Controls, pages and windows / Control functions
  • Belonging of controls
  • Using retrieved controls
  • Tab controls with dynamic tabs
  • List sub-elements
  • WLanguage error
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Returns the name of Nth control found in the specified element. This element must be displayed.
In a loop, this function is used to enumerate the controls found in an element.
WINDEVWINDEV Mobile The specified element can be a window, a report, a group of controls, a Tab control, a Looper control or a supercontrol. The Toolbar controls and the SideBar controls are not supported.
WEBDEV - Server code The specified element can be a page, a report, a group of controls, a Looper control, a break in a Looper control, a Cell control or a supercontrol
Example
WINDEVReports and QueriesJavaUser code (UMC)
// Nom du champ 7 de la fenêtre "FEN_FenêtreSaisie"
ResChamp = EnumControl(FEN_FenêtreSaisie, 7)
WINDEVReports and QueriesJavaUser code (UMC)
// Remplir un champ Combo avec la liste des champs de la fenêtre
i is int = 1
ResChamp is string
ResChamp = EnumControl(FEN_FenêtreSaisie, i)
WHILE ResChamp <> ""
	i++
	ListAdd(COMBO_ListeChamp, ResChamp)
	ResChamp = EnumControl(FEN_FenêtreSaisie, i)
END
WEBDEV - Server codeAjax
// Nom du champ 7 de la page "PAGE_MaPage"
ResChamp = EnumControl(PAGE_MaPage, 7)
WEBDEV - Server codeAjax
// Remplir un champ Combo avec la liste des champs de la page
i is int = 1
ResChamp is string
ResChamp = EnumControl(PAGE_MaPage, i)
WHILE ResChamp <> ""
	i++
	ListAdd(COMBO_ListeChamp, ResChamp)
	ResChamp = EnumControl(PAGE_MaPage, i)
END
Syntax
<Result> = EnumControl(<"Parent" object> , <Control number> [, <Type of enumeration>])
<Result>: Character string
  • Name of control found,
  • Empty string ("") if no control was found.
<"Parent" object>: Character string
Name of the "parent" object (containing the control). This parameter corresponds to the name of a window, a Looper control, a break in a Looper control, a group, a Tab control, a supercontrol o a report.
If the "parent" object is a Tab field, the following notation should be used: <Tab field name>[<Tab pane number>]. For example: ONG_Onglet1[2].
WEBDEV - Server code Name of the "parent" object (containing the control). This parameter corresponds to the name of a page, a report, a group of controls, a Looper control, a break in a Looper control, a Cell control or a supercontrol.
<Control number>: entier
Number of the control whose name you want to get. Each control is associated with a number. This number corresponds to:
  • the creation order of the controls (by default) if the type of enumeration is performed by the byCreationOrder constant
  • the tab order (which means the order in which the controls gain focus in the "parent" object) if the type of enumeration is performed with the byTabOrder constant.
    The F5 key is used to see the navigation order in the window editor and in the page editor
<Type of enumeration>: Optional Integer constant
Order in which the enumeration is performed:
byCreationOrder
(Default value)
Enumeration performed according to the creation order of controls (in the editor or by ControlClone).
byTabOrderEnumeration performed according to the navigation order with the tab key (Tab). The controls that are not accessible with the tab key (Tab) are listed at the end.
byZOrderEnumeration performed according to the Z-index of controls, from the lowest one to the highest one.

WEBDEV - Server code This parameter is not available.
Remarks

Belonging of controls

Only the controls that directly belong to the specified "parent" object are enumerated.
For example, if <"Parent" object> corresponds to the name of a window or page, EnumControl only affects the controls that directly belong to this window or page. EnumControl cannot be used to retrieve the names of the controls belonging to the Tab controls or the supercontrols of this window (or page).

Using retrieved controls

When the name of a control retrieved by EnumControl is contained in a variable, the control itself can be used thanks to indirection operators (braces { and }). Example:
// Nom du champ 7 de la page
NomChamp is string = EnumControl(MyPage, 7)
// Libellé du champ
ToastDisplay({NomChamp}..Caption)
WEBDEV - Server code To use an indirection on a control of a page, the option "Allow indirections (slows the execution down)" must be checked ("Details" tab in the control description window).
WINDEV

Tab controls with dynamic tabs

If <"Parent" object> corresponds to the name of a Tab control with dynamic tabs, the aliases of the dynamic tabs are enumerated.

List sub-elements

The EnumControlfunction, used in a loop, lists the fields in a window..
However, this function does not go down the tree structure of fields: for example, it does not list the fields contained in the panes of a Tab Control in a window. To go down the field tree structure, you can use the EnumSubElement function:
j is int = 1
ResChamp is string
ResChamp = EnumControl(MyWindow.Nom, j)

WHILE ResChamp <> ""
	j++
	Trace(ResChamp)
	ListeElément(MyWindow.Nom + "." + ResChamp)
	ResChamp = EnumControl(MyWindow.Nom, j)
END

INTERNAL PROCEDURE ListeElément (NomElt)
	i is int = 1
	sReschampSousElt is string
	sReschampSousElt = EnumSubElement(NomElt, i)
	WHILE sReschampSousElt <> ""
		i++
		Trace(NomElt+"."+sReschampSousElt)
		ListeElément(NomElt +"."+ sReschampSousElt)
		sReschampSousElt = EnumSubElement(NomElt, i)
	END
END

WLanguage error

A WLanguage error occurs if:
  • <Control number> is negative.
  • <Control number> is greater than the number of controls found in <"Parent" object> +1. This is used to avoid the endless loops.
  • <"Parent" object> is not a window, a page, a report, a group, a Tab control or a supercontrol.
Component: wd300vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo PCSOFT
Exemplo de uso do EnumControl
Lista objetos da tela
Inclusive os sub objetos

j is int = 1
ResChamp is string
ResChamp = EnumControl(MyWindow.Name, j)
WHILE ResChamp <> ""
j++
Trace(ResChamp)
listeélément(MyWindow.Name+"."+ResChamp)
ResChamp = EnumControl(MyWindow.Name, j)
END


INTERNAL PROCÉDURE listeélément(NomElt)
i is int = 1
sResChampSousElt is string
sResChampSousElt = EnumSubElement(NomElt, i)
WHILE sResChampSousElt <> ""
i++
Trace(NomElt+"."+sResChampSousElt)
listeélément(NomElt+"."+sResChampSousElt)
sResChampSousElt = EnumSubElement(NomElt, i)
END
END


The Free Technical Support is entirely at your service.
Boller
14 Dec. 2023
PROCEDURE evento_lista_objetos_gpw(ninstancia)
i is int = 1
objs_form is string = ""
sControlName is string = ""

ninstancia = ninstancia

<COMPILE IF Configuration<>"iOS application" AND Configuration<> "Android application">

arrayControles is array of string

IF ninstancia = 0 THEN

RESULT ""

ELSE

NomeForm is string = m_Tabela[ninstancia].gs_nomeJanela

WHEN EXCEPTION IN

sControlName = gpwEnumControl(NomeForm, i)
indirection is string = NoSpace(NomeForm) +"."+ NoSpace(sControlName)
Add(arrayControles,indirection)

LOOP(5000)

// Next control
i++

sControlName = gpwEnumControl(NomeForm, i)

IF sControlName <> ""
indirection = NoSpace(NomeForm) +"."+ NoSpace(sControlName)
Add(arrayControles,indirection)
Trace(indirection)
ELSE
BREAK
END

END

RESULT arrayControles


DO
IF ExceptionInfo(errCode) THEN
RESULT arrayControles
END
END


END

<END>
BOLLER
02 Sep. 2023
PROCEDURE evento_lista_objetos(ninstancia)
i is int = 1
objs_form is string = ""
sControlName is string = ""
sControles is string = ""

arrayControles is array of string

IF ninstancia = 0 THEN

RESULT ""

ELSE

NomeForm is string = m_Tabela[ninstancia].gs_nomeJanela

WHEN EXCEPTION IN

sControlName = EnumControl(NomeForm, i)
indirection is string = NoSpace(NomeForm) +"."+ NoSpace(sControlName)
Add(arrayControles,indirection)

LOOP(5000)

Trace(sControlName)

i++

sControlName = EnumControl(NomeForm, i)

IF sControlName <> ""
indirection = NoSpace(NomeForm) +"."+ NoSpace(sControlName)
Add(arrayControles,indirection)
Trace(indirection)
ELSE
BREAK
END

END

RESULT arrayControles

DO
IF ExceptionInfo(errCode) THEN
RESULT arrayControles
END
END

END
Boller
02 Sep. 2023

Last update: 03/27/2025

Send a report | Local help