Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BINDEVENT() and properties
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00809607
Message ID:
00809615
Vues:
37
>VFP help says: You can use BINDEVENT() to bind events, properties, or methods...
>
>To bind properties, have anyone tried this and got it to work?
>
>AT

Here's the code that shows bindig to the form's native and custom properties. Keep in mind that method bind to the property wouldn't fire if property was changed by VFP internally, only if property's been changed by assigning of the new value. In the sample form below, OtheMethod() wouldn't fire if you use MINIMIZE/RESTORE or MAXIMIZE buttons of the form.
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form


	Top = 0
	Left = 2
	Height = 212
	Width = 353
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	myproperty = .F.

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 96, ;
		Left = 36, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "MyProperty", ;
		Name = "Command1"

	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 96, ;
		Left = 204, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "WindowState", ;
		Name = "Command2"

	PROCEDURE mymethod
		DEBUGOUT TIME(), PROGRAM(), Thisform.MyProperty
	ENDPROC

	PROCEDURE othermethod
		DEBUGOUT TIME(), PROGRAM(), Thisform.WindowState
	ENDPROC

	PROCEDURE Init
		BINDEVENT(Thisform, "myproperty", Thisform, "mymethod")
		BINDEVENT(Thisform, "WindowState", Thisform, "OtherMethod",2)
	ENDPROC


	PROCEDURE command1.Click
		Thisform.myproperty = DATETIME()
	ENDPROC

	PROCEDURE command2.Click
		IF Thisform.WindowState = 0
			Thisform.WindowState = 2
		ELSE
			Thisform.WindowState = 0
		ENDIF
	ENDPROC
ENDDEFINE
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform