Page 1 of 2

ChildList() of FORM ?

Posted: Tue Dec 17, 2019 7:01 am
by AUGE_OHR
hi,

a FORM have OnGotFocus() which i want to re-direct to set focus on 1st Child, how with HMG :?:

under Xbase++ i use

Code: Select all

   aChild := oDialog:DrawingArea:ChildList()
   SetAppFocus( aChild[1] )

Re: ChildList() of FORM ?

Posted: Tue Dec 17, 2019 7:20 am
by SALINETAS24
Hola, igual es esto lo que buscas

<WindowName>.FocusedControl

Sl2

Re: ChildList() of FORM ?

Posted: Tue Dec 17, 2019 7:16 pm
by AUGE_OHR
hi,
SALINETAS24 wrote: Tue Dec 17, 2019 7:20 am Hola, igual es esto lo que buscas

Code: Select all

<WindowName>.FocusedControl
thx for Tip
FocusedControl Property
Retrieves the focused control name of a Window
my Problem that i want to SET focus to a Child Control ... i exist

Code: Select all

   nPosi := ASCAN(aChild, {|e| e = MySeekControl } )
   IF nPosi > 0
      SetAppFocus( aChild[nPosi] )
most it is the 1St Child but i need a "List" of all Child to work with

Re: ChildList() of FORM ?

Posted: Tue Dec 17, 2019 8:08 pm
by SALINETAS24
Hola.., siento no entender lo que buscas.
Creo entender que necesitas la lista de controles o de Child que tienes.., quizas esto te pueda poner sobre la pista...

viewtopic.php?f=24&t=5805&p=56314&hilit ... LES#p56314

Un saludo,

Re: ChildList() of FORM ?

Posted: Wed Dec 18, 2019 1:45 am
by andyglezl
Maybe...

Code: Select all

In each DEFINE...

	AADD( aChildForms, { nForm, cChildForm, cPanelForm, .T. } )

Validate...

	FOR i = 1 TO HMG_LEN( aChildForms )
		IF hb_AScan( aChildForms[i] , cNombChild2Focus, .T. ) > 0
			DoMethod( cNombChild2Focus, "SetFocus")
			EXIT
		ENDIF
	NEXT i

Re: ChildList() of FORM ?

Posted: Wed Dec 18, 2019 2:42 am
by AUGE_OHR
YES :D

i found this

Code: Select all

Function GetControls( cForm )
Local hWnd := GetFormHandle( cForm )
Local aControls := {}		//List of controls {ControlType, ControlName}
AEVAL( _HMG_SYSDATA[ 4 ], { | hCtrWnd, nPos | IF( hCtrWnd == hWnd, AADD( aControls , { _HMG_SYSDATA[ 1, nPos ], _HMG_SYSDATA[ 2, nPos ] }), Nil ) } )
MsgDebug( 'List of controls', aControls)
Return aControls
now i have to find out how to use it ...

thx all for help

Re: ChildList() of FORM ?

Posted: Wed Dec 18, 2019 2:45 am
by AUGE_OHR
andyglezl wrote: Wed Dec 18, 2019 1:45 am

Code: Select all

In each DEFINE...
	FOR i = 1 TO HMG_LEN( aChildForms )
thx for help.

Question : is HMG_LEN() different to LEN() function :?:

Re: ChildList() of FORM ?

Posted: Wed Dec 18, 2019 2:53 am
by andyglezl
HMG_LEN() = Unicode
LEN() = ANSI

Re: ChildList() of FORM ?

Posted: Wed Dec 18, 2019 12:27 pm
by edk
andyglezl wrote: Wed Dec 18, 2019 1:45 am Maybe...

Code: Select all

In each DEFINE...

	AADD( aChildForms, { nForm, cChildForm, cPanelForm, .T. } )

Validate...

	FOR i = 1 TO HMG_LEN( aChildForms )
		IF hb_AScan( aChildForms[i] , cNombChild2Focus, .T. ) > 0
			DoMethod( cNombChild2Focus, "SetFocus")
			EXIT
		ENDIF
	NEXT i
@andyglezl It will not be correct, because you would have to handle the window closing event and remove it from the aChildForms array.

If you want to check for instances of a given window type, you can use this function:

Code: Select all

Function GetWindowsByType( cType )
Local aForms := {}		//List of forms { WindowName, WindowType, WindowIsDeleted, WindowIsActive, WindowHandle, WindowParentHandle }
Default cType :=''
/*
	empty - all types
	A - main 
	S - standard
	C - child
	M - modal
	P - panel
	X - splitchild
*/
IF Upper(Left(cType,1))$"ASCMPX" .OR. EMPTY( cType )
	AEVAL( _HMG_SYSDATA[ 69 ], { | cWndType, nPos | IF( Empty( cType ) .OR. cWndType==Upper(Left (cType, 1)) , ;
		AADD( aForms , ;
			{ _HMG_SYSDATA[ 66, nPos ], ;	//_HMG_aFormName
			  _HMG_SYSDATA[ 69, nPos ], ;	//_HMG_aFormType
			  _HMG_SYSDATA[ 65, nPos ], ;	//_HMG_aFormDeleted
			  _HMG_SYSDATA[ 68, nPos ], ;	//_HMG_aFormActive
			  _HMG_SYSDATA[ 67, nPos ], ;	//_HMG_aFormHandle
			  _HMG_SYSDATA[ 70, nPos ]}),;	//_HMG_aFormParentHandle
		Nil ) } )
ELSE
	MsgStop('Function GetWindowsByType(): invalid window type "' + cType + '"' )
ENDIF

Return aForms
Sample:
GetWindowsByType.7z
(1.49 KiB) Downloaded 205 times
Edward.

Re: ChildList() of FORM ?

Posted: Wed Dec 18, 2019 2:37 pm
by andyglezl
@andyglezl It will not be correct, because you would have to handle the window closing event and remove it from the aChildForms array.

If you want to check for instances of a given window type, you can use this function:
Edward.
Hola EDK

(Lo siento, me enfoque en lo que yo estaba haciendo...)

Tienes razón, aunque si estoy controlando el cierre de las ventanas.
En mi caso, solo guardo algunos datos de las ventanas CHILD (no todas) que voy creando
en esa opción del programa para poderlos utilizar mas delante hasta el cierre de la misma.
(de hecho, lo estoy utilizando con tu ejemplo) https://www.hmgforum.com/viewtopic.php? ... 9&start=10
*-----------------------------------------------------------------------------------------------------------------------------------------
Hi EDK

(I'm sorry, I focus on what I was doing ...)

You are right, although I am controlling the closing of the windows.
In my case, only save some data from the CHILD windows (not all) that I am creating
in that option of the program to be able to use them more ahead until the closing of the same.
(in fact, I'm using it with your example) https://www.hmgforum.com/viewtopic.php? ... 9&start=10

Gracias por esta nueva herramienta que nos compartes !
*-------------------------------------------------------------------------
Thank you for this new tool that you share with us!