CUANTOS CONTROLES HAY EN UNA WINDOW

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

CUANTOS CONTROLES HAY EN UNA WINDOW

Post by SALINETAS24 »

Hola a todos, tengo una pregunta.
¿ Hay alguna forma de saber cuantos controles tenemos en una Window.?
¿ Y cuantos de ellos son TEXTBOX...?

No se si me he explicado correctamente.
Lo que necesito es poder un momento dado inicializar todos los TEXTBOX, ya sea a "0" o en Blanco.
Gracias.
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: CUANTOS CONTROLES HAY EN UNA WINDOW

Post by edk »

Try this way:

Code: Select all

#include "hmg.ch"

MEMVAR _HMG_SYSDATA

proc main
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'Test';
		MAIN

      DEFINE MAIN MENU
              POPUP 'Standard'
                ITEM 'Open Window' ACTION {|| DoWindow2() } 
              END POPUP
      END MENU

      @ 40,20 LABEL Win_1_Label_1 VALUE "L1"
      
      @ 20,30 BUTTON Win_1_Button_1 Caption 'Controls' WIDTH 100 HEIGHT 20 ACTION GetControls (ThisWindow.Name)
      
	END WINDOW

	activate window Form_1
retu

//*****************************************************************************
func DoWindow2()
	DEFINE WINDOW Form_2 ;
		AT 0,0 ;
		WIDTH 600 HEIGHT 400 ;
		TITLE 'Win 2' 

		@ 20,40 BUTTON Win_2_Button_1 caption 'Win 3' WIDTH 100 HEIGHT 20 ACTION {|| DoWindow3() }
		
		@ 40,20 LABEL Win_2_Label_1 VALUE "L1"
		@ 60,20 LABEL Win_2_Label_2 VALUE "L2"
		
		@ 100,30 BUTTON Win_2_Button_2 Caption 'Controls' WIDTH 100 HEIGHT 20 ACTION GetControls (ThisWindow.Name)

	END WINDOW

	activate window Form_2
return

//*****************************************************************************
func DoWindow3()
	DEFINE WINDOW Form_3 ;
		AT 0,0 ;
		WIDTH 600 HEIGHT 400 ;
		TITLE 'Win 3' 

		@ 50,100 BUTTON Win_3_Button_1 caption 'OK' WIDTH 100 HEIGHT 20 ACTION {|| MsgBox('OK') }
		
		@ 70,20 LABEL Win_3_Label_1 VALUE "L1"
		@ 90,20 LABEL Win_3_Label_2 VALUE "L2"
		@ 110,20 LABEL Win_3_Label_3 VALUE "L3"
		
		@ 130,30 BUTTON Win_3_Button_3 Caption 'Controls' WIDTH 100 HEIGHT 20 ACTION GetControls (ThisWindow.Name)

	END WINDOW

	activate window Form_3
return


************************************************************************************
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

User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: CUANTOS CONTROLES HAY EN UNA WINDOW

Post by SALINETAS24 »

Muchas gracias Edk...
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
Post Reply