Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to bind event on enabled property ?
Message
 
À
04/04/2012 11:16:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01540274
Message ID:
01540298
Vues:
49
>i want to execute a procedure whenever a button's enabled status change.
>how to do it ?

You can do something like this:
loForm = CREATEOBJECT('myForm')
loForm.Show(1)

DEFINE Class myForm as FORM
	ADD OBJECT Button1 as CommandButton WITH Caption = 'Click Me', Enabled = .t., left = 0, top = 2, height = 24
	ADD OBJECT Button2 as CommandButton WITH Caption = 'Disable "Click Me" button', Enabled = .t., left = 100, top = 2, WIDTH = 175, height = 24
	
	PROCEDURE Button2.Click()
		thisform.Button1.Enabled = not thisform.Button1.Enabled
	ENDPROC
	
	PROCEDURE Button1StatusChange()
		thisform.Button2.Caption = IIF(thisform.Button1.Enabled, 'Disable', 'Enable') + ' "Click Me" button'
	ENDPROC
	
	FUNCTION Init()
		BINDEVENT(thisform.Button1, 'Enabled', thisform, 'Button1StatusChange', 1) && 1 so it changes the property before firing the Button1StatusChange method
		RETURN DODEFAULT()
	ENDFUNC 
ENDDEFINE
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform