Page 1 of 1

Find a Child's Control's Parent Control

Posted: Tue Jan 18, 2022 11:38 pm
by Red2
Hi all, I am stuck!

I have both BROWSE and GRID controls on pages of a TAB control (on a child FORM).
From BROWSE and GRID code I need to reference the parent TAB's properties.

My Question: How can I programmatically find:
The NAME of the "parent" TAB control (for a known child BOWSE or GRID control)?

Thank you for your help!

-----------------------------------
Google Spanish:
Hola a todos, estoy atascado!

Tengo los controles BROWSE y GRID en las páginas de un control TAB (en un FORM secundario).
Desde el código BROWSE y GRID, necesito hacer referencia a las propiedades de la TAB principal.

Mi pregunta: ¿Cómo puedo encontrar programáticamente:
¿El NAME del control TAB "principal" (para un control secundario conocido BOWSE o GRID)?

¡Gracias por tu ayuda!

Red2

Re: Find a Child's Control's Parent Control

Posted: Wed Jan 19, 2022 9:48 am
by AUGE_OHR
hi,

you BROWSE or GRID are "on TAB" and you want to know which TAB :?:

Code: Select all

   nActive := Tab_Left.Value // which TAB is active

Re: Find a Child's Control's Parent Control

Posted: Wed Jan 19, 2022 9:56 am
by SALINETAS24
Red2 wrote: Tue Jan 18, 2022 11:38 pm Hi all, I am stuck!

*** / ***
Red2
Hola, no termino de entenderte, pero quizás esto trozo de código que encontre te pueda servir.
Con esta función obtienes todos los controles de la WINDOW, y mientras tengas un solo "TAB" no tendrás problema.

Code: Select all

Function GetControls( cForm )
Local hWnd := GetFormHandle( cForm )
Local aControls := {}		//Lista de Controles {ControlType, ControlName}
Local cNameControl:=""
AEVAL( _HMG_SYSDATA[ 4 ], { | hCtrWnd, nPos | IF( hCtrWnd == hWnd, AADD( aControls , { _HMG_SYSDATA[ 1, nPos ], _HMG_SYSDATA[ 2, nPos ] }), Nil ) } )

FOR nPos=1 TO LEN(aControls)
	IF aControls[nPos][1]="TAB"
		MSGBOX("Nombre TAB -->  "+aControls[nPos][2])
		cNameControl:=	aControls[nPos][2]
		EXIT
	ENDIF
NEXT

// Ver la lista entera 
MsgDebug( 'List of controls', aControls)

Return cNameControl

Saludos y una cervecita bien fresquita..!!!

Re: Find a Child's Control's Parent Control

Posted: Thu Jan 20, 2022 1:35 am
by Red2
Hi SALINETAS24,

¡Muchas gracias! Su código era exactamente lo que estaba buscando. ¡Problema resuelto!

Thank you so much! Your code was exactly what I was looking for. Problem solved!

Red2