Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bind Event to a Property
Message
 
To
24/07/2018 10:52:16
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01661333
Message ID:
01661338
Views:
64
>I have searched the web for examples and explanations as to binding an event to a property. From the little I have found it tells me that an event can bond, but only when the property value changes (like Assign). But the event only is fired After the change occurs. This prevents any pre-change validation, or decision to stop the change from occurring. Also, the documents indicate that an Access like binding could be done, but I have found nothing explaining how. The big question is; does anyone have a complete instructions on how set the binding up, and how to determine (and set) the value of the property in the event?

You can use BINDEVENT with nflag 0 (it's documented in help), which triggers the delegate before the event, but I don't know how to evaluate the newValue
LOCAL lo, evC, loEx As Exception 
lo = CREATEOBJECT("Empty")
ADDPROPERTY(m.lo, "evProp", 0)
*
evC = CREATEOBJECT("evCtrl")
BINDEVENT(m.lo, "evProp", m.evC, "testAssignBefore", 0)
TRY
	lo.EvProp = 44
CATCH TO m.loEx
	IF m.loEx.ErrorNo = 1743
		MESSAGEBOX("Invalid property value")
	ENDIF
ENDTRY

***========================
DEFINE CLASS evCtrl AS Custom
***========================

	***************************
	PROCEDURE testAssignBefore
	***************************
	LOCAL lo
	LOCAL ARRAY laEv[1]
	AEVENTS(laEv, 0)
	lo = laEv[1]
*** if new value not ok
	ERROR 1743
	
ENDDEFINE
Previous
Reply
Map
View

Click here to load this message in the networking platform