Functions to tell the control type

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Functions to tell the control type

Post 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
Just Hmg It !
skonuk
Posts: 28
Joined: Fri Sep 17, 2010 7:37 pm
Location: turkey-bursa

Re: Functions to tell the control type

Post by skonuk »

getcontroltype (Ccontrol, CWindow) ='TEXTBOX' vs vs vs vs

If you examine the call maybe that is the answer.

Salim
Bursa-Turkey
*----------------------------
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Functions to tell the control type

Post by Javier Tovar »

Hola skonuk,

Donde puedo ver esa función? Gracias.

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

Hello skonuk,

Where I can see that function? Thank you.

regards
skonuk
Posts: 28
Joined: Fri Sep 17, 2010 7:37 pm
Location: turkey-bursa

Re: Functions to tell the control type

Post 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.
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Functions to tell the control type

Post by Javier Tovar »

Thank you very much for the information.
regards
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Functions to tell the control type

Post by hmgchang »

Thks mr. Skonuk & mr. Tovar...
Just Hmg It !
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Functions to tell the control type

Post 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
BPD
Convert Dream into Reality through HMG
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Functions to tell the control type

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Functions to tell the control type

Post by Javier Tovar »

Hola Pablo César,

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

Saludos
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Functions to tell the control type

Post by hmgchang »

Thks All for valuable infos... :)
Just Hmg It !
Post Reply