Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP 8 Empty Class
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00793345
Message ID:
00793681
Views:
54
>BTW, if I bindevent to a property of many instances of the same classes
>how can I know to which object you are binded?
>
>I suppose that I have to create an instance of the "event" class for each
>and store a reference to the "prop only" object in it...

If I understand correctly, you could check for the name of the object calling the bound method. Though not a generic way to do so, something like the following:
PRIVATE o, x
o = NEWOBJECT('Empty')
ADDPROPERTY(o, 'FireInit')
ADDPROPERTY(o, 'Name', 'O-Object')
p = NEWOBJECT('Empty')
ADDPROPERTY(p, 'FireInit')
ADDPROPERTY(p, 'Name', 'P-Object')
x = NEWOBJECT('EmptyMethods')
BINDEVENT(o, 'FireInit', x, 'FireInit', 1)
BINDEVENT(p, 'FireInit', x, 'FireInit', 1)
CLEAR
o.FireInit = [o1]
p.FireInit = [p1]


DEFINE CLASS EmptyMethods AS Custom

	PROCEDURE FireInit
*!*			IF TYPE('o.FireInit') = "N"
*!*				o.FireInit = o.FireInit + 1
*!*			ELSE
*!*				o.FireInit = 1
*!*			ENDIF
		lnRetVal = AEVENTS(laEvents, 0)
		WAIT WINDOW 'FireInit fired - Value =' ;
                     + TRANSFORM(laEvents[1,1].FireInit) ;
                     + '.  Called from ' + laEvents[1,1].Name
	ENDPROC
	PROCEDURE Release
		RELEASE THIS
	ENDPROC

ENDDEFINE
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform