Página 1 de 1

list of controls

Publicado: Mié May 25, 2022 1:50 pm
por Hurricane
Hi,

At runtime, does Xailer have any functions or methods that I read all controls on the Form? Similar to pascal:

Código: Seleccionar todo

  for n:= 0 to ComponentCount-1 do
  begin
  ShowMessage(Components[n].ClassName);
  end; 
I know that each container has its list of controls/objects, that's how I do it.

regards,

Re: list of controls

Publicado: Mié May 25, 2022 2:40 pm
por Pedro Gil
Hi,

Do you mean something like the following code?

LOCAL oCtl

FOR EACH oCtl IN ::aControls
oCtl:ClassName()
NEXT

Regards.

Re: list of controls

Publicado: Mié May 25, 2022 3:45 pm
por Hurricane
Not. I already do this and recursively read all controls in any* container.
Pedro Gil escribió: Mié May 25, 2022 2:40 pm Do you mean something like the following code?

LOCAL oCtl

FOR EACH oCtl IN ::aControls
oCtl:ClassName()
NEXT

Re: list of controls

Publicado: Mié May 25, 2022 4:01 pm
por ignacio
Hi,

Surely you know hot to do a recursive function. Just in case:

Código: Seleccionar todo

FUNCTION GetControls( oForm, aControls )

   LOCAL oCtl
   DEFAULT aControls TO {}

  FOR EACH oCtl IN oForm:aControls 
      Aadd( aControls, oCtl )
      IF oCtl:IsKindOf( "TWinControl" )
         GetControls( oCtl, @aControls )
     ENDIF
  NEXT

RETURN aControls
Regards,

Re: list of controls

Publicado: Mié May 25, 2022 4:52 pm
por Hurricane
I did some tests and it works fine. I will update my function. Thanks.
ignacio escribió: Mié May 25, 2022 4:01 pm

Código: Seleccionar todo

FUNCTION GetControls( oForm, aControls )
regards,