Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP objects talking to each other
Message
From
05/12/2002 10:59:34
 
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00729821
Message ID:
00729899
Views:
32
So, to talk to another class I would call the function in the mediator, passing the name of the class, which will in turn call the function in the relevent class?

Kev

>Sure, here is an example I put together for you, somehow it even works!
>
>Local lof As Form
>
>lof = Createobject('MediatorForm')
>lof.Show(1)
>
>
>Define Class MediatorForm As Form
>	Visible = .T.
>	AutoCenter = .T.
>	Height = 80
>	Width = 160
>	Caption = 'Mediating Container'
>
>	Add Object tickletext1 As tickletext ;
>		WITH ;
>		top = 10,;
>		left = 10, ;
>		visible = .T.
>
>
>	Add Object tickletext2 As tickletext ;
>		WITH ;
>		top = 10, ;
>		left = 80, ;
>		visible = .T.
>
>	Function showentry
>	Lparameters tcName
>	If tcName = This.tickletext1.Name
>		This.tickletext2.Value = This.tickletext1.Value
>	Else
>		This.tickletext1.Value = This.tickletext2.Value
>	Endif
>	Endfunc
>
>Enddefine
>
>
>Define Class tickletext As TextBox
>	Width = 70
>
>	Function LostFocus
>	This.Parent.showentry(This.Name)
>	Endfunc
>Enddefine
>
>
>Glenn
>>Hi
>>
>>Have you got any examples/notes on this method? I've never tried it before.
>>
>>Thanks
>>Kev
>>
>>>I believe that it is "Best Practice" to invoke a mediator for this purpose. The parent object should communicate with both objects. In this case the object which triggers the event should notify the Parent object and then the parent object should take any necessary actions with it's children objects.
>>>
>>>Glenn
>>>
>>>>Hi
>>>>
>>>>What's the best way to do the following? I have an object that needs to call methods in another object.
>>>>
>>>>Is it best to create the object you want to talk to, in a property on the object?
>>>>
>>>>Or are there other/better ways?
>>>>
>>>>Thanks
>>>>Kev
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform