Page 1 of 1

Functions to tell the control type

Posted: Mon Jan 20, 2014 3:45 am
by hmgchang
Morning,
1. How to know a control type ( TEXTBOX, COMBOBOX etc.) from a control name.
( something like VALTYPE() function to know the type of a variable)

thks n rgds
Chang

Re: Functions to tell the control type

Posted: Mon Jan 20, 2014 5:31 pm
by skonuk
getcontroltype (Ccontrol, CWindow) ='TEXTBOX' vs vs vs vs

If you examine the call maybe that is the answer.

Salim
Bursa-Turkey
*----------------------------

Re: Functions to tell the control type

Posted: Mon Jan 20, 2014 6:09 pm
by Javier Tovar
Hola skonuk,

Donde puedo ver esa función? Gracias.

Saludos
//////////////////////////////////////////////////////////////////////////////////

Hello skonuk,

Where I can see that function? Thank you.

regards

Re: Functions to tell the control type

Posted: Mon Jan 20, 2014 7:54 pm
by skonuk

Code: Select all

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 230 HEIGHT 300 ;
		TITLE "HMG Demo" ;
		MAIN 
	

      @ 010,10 LABEL Label_1 VALUE "Label_1" WIDTH 200 ;
         TOOLTIP "Label 1"
  
      
		@ 30,10 COMBOBOX Combo_1 ;
			WIDTH 100 ;
			ITEMS { '1 | One' , '2 | Two' , '3 | Three' }
      
    @ 50,10 TEXTBOX TEXT_1 WIDTH 100 VALUE ''
    
    @ 80,70  BUTTON Button_1  CAPTION 'TEST_1' ACTION MSGINFO(GETCONTROLTYPE('LABEL_1','FORM_1'))         WIDTH 50 HEIGHT 50
    
    @ 120,70 BUTTON Button_2  CAPTION 'TEST_2' ACTION MSGINFO(GETCONTROLTYPE('COMBO_1','FORM_1'))    WIDTH 50 HEIGHT 50
    
    @ 150,70 BUTTON Button_3 CAPTION 'TEST_3' ACTION MSGINFO(GETCONTROLTYPE('TEXT_1','FORM_1')) WIDTH 50 HEIGHT 50
    
  
  
	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return Nil


\ HMG \ SOURCE \ H_CONTROLMISC.PRG can SEE


If you search 'GETCONTROLTYPE' in FORUM, YOU WILL SEE FURTHER EXAMPLES.


ESGICI
THERE'RE MISSING FUNCTIONS RELATED TO THIS DOCUMENTATION.

Re: Functions to tell the control type

Posted: Mon Jan 20, 2014 11:34 pm
by Javier Tovar
Thank you very much for the information.
regards

Re: Functions to tell the control type

Posted: Mon May 12, 2014 6:54 am
by hmgchang
Thks mr. Skonuk & mr. Tovar...

Re: Functions to tell the control type

Posted: Mon May 12, 2014 11:08 am
by bpd2000
Another Example
#include "minigui.ch"

Function Main

DEFINE WINDOW Win_0 ;
ROW 0 ;
COL 0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE 'Panel Window Demo' ;
WINDOWTYPE MAIN

DEFINE BUTTON BUTTON_1
ROW 160
COL 90
WIDTH 200
CAPTION 'Click Me!'
ACTION Test()
DEFAULT .T.
END BUTTON

END WINDOW

Center Window Win_0

Activate Window Win_0

Return Nil

Procedure Test

DEFINE WINDOW Win_1 ;
ROW 0 ;
COL 0 ;
WIDTH 500 ;
HEIGHT 300 ;
TITLE 'Panel in Modal Window' ;
WINDOWTYPE MODAL

DEFINE LABEL LABEL_0
ROW 10
COL 50
VALUE 'Press F2 and F3 key ...'
WIDTH 300
END LABEL

ON KEY ESCAPE ACTION ThisWindow.Release

DEFINE WINDOW Win_2 ;
ROW 30 ;
COL 30 ;
WIDTH 300 ;
HEIGHT 200 ;
VIRTUAL WIDTH 400 ;
VIRTUAL HEIGHT 400 ;
WINDOWTYPE PANEL

DEFINE LABEL LABEL_1
ROW 10
COL 10
VALUE 'Panel window...'
WIDTH 300
END LABEL

DEFINE BUTTON BUTTON_1
ROW 40
COL 10
CAPTION 'Click Me!'
ACTION MsgInfo('Clicked!')
DEFAULT .T.
END BUTTON

DEFINE LABEL LABEL_2
ROW 90
COL 10
VALUE "Can do this!"
WIDTH 300
END LABEL

DEFINE TEXTBOX TEXT_1
ROW 120
COL 10
VALUE 'Test'
END TEXTBOX

DEFINE TEXTBOX TEXT_2
ROW 150
COL 10
VALUE 'Test'
END TEXTBOX

DEFINE TEXTBOX TEXT_3
ROW 180
COL 10
VALUE 'Test'
END TEXTBOX

DEFINE TEXTBOX TEXT_4
ROW 210
COL 10
VALUE 'Test'
END TEXTBOX

DEFINE TEXTBOX TEXT_5
ROW 240
COL 10
VALUE 'Test'
END TEXTBOX

END WINDOW

DEFINE TEXTBOX TEXT_1
ROW 300
COL 10
VALUE 'Test'
END TEXTBOX

ON KEY F2 ACTION MsgInfo ( Win_2.FocusedControl, GetControlType(( Win_2.FocusedControl ), 'Win_2') )
ON KEY F3 ACTION Test2('Win_2')

END WINDOW

Center Window Win_1

// Panel windows are automatically activated through its parent
// so, only Win_1 must be activated.

Activate Window Win_1

Return


PROCEDURE Test2(cForm)
LOCAL cFoco, cTipo
cFoco := GetProperty(cForm,'FOCUSEDCONTROL')
cTipo := GETCONTROLTYPE( cFoco, cForm)
MSGINFO( cForm +CRLF+ cFoco +CRLF+ cTipo)
RETURN NIL

Functions to tell the control type

Posted: Mon May 12, 2014 11:44 am
by Pablo César
skonuk wrote:
Javier Tovar wrote:Where I can see that function? Thank you.
THERE'RE MISSING FUNCTIONS RELATED TO THIS DOCUMENTATION.
Yes you are right ! There is not any documentation about this important functions. But at least we all have sources codes to be studied.

Just to complement information. There is another also important function to GET type of Control:

GetFocusedControlType()

See here to see a recently example.

Re: Functions to tell the control type

Posted: Mon May 12, 2014 4:52 pm
by Javier Tovar
Hola Pablo César,

Gracias por tus enseñanzas! en la semana experimento con estas funciones. :D :D :D

Saludos

Re: Functions to tell the control type

Posted: Tue May 13, 2014 5:35 am
by hmgchang
Thks All for valuable infos... :)