General information
Category:
COM/DCOM and OLE Automation
Hi Al,
The Callback code is an example of how one could implement COM callbacks.
The ADO sample in the same paper shows how a VFP app can call a COM object (ADO) to do work. While the work is being done in that server, the server can call back to the client (VFP) as various events occur. Perhaps this could be a progress indicator. For ADO, the Recordset has WillMove, WillChange, MoveComplete, etc. events can be called on a VFP client object.
The Callback sample demonstrates how one can do the same thing with their custom COM server. Perhaps you are the author of a VFP COM server that does something like ADO. You have a method that does something, and you want to call back into the client for certain events (BeforeBuy, AfterBuy) so the client can take appropriate action.
The IDemoEvents interface is defined in the class DemoEvents. By COM convention, the interface is the class name preceded by “I”. Thus the IDemoEvents interface has 2 methods: BeforeBuyStock, and AfterBuyStock
The CCallBack class implements the interface and is instantiated. It is then passed to an instance of the COM server. Now when the COM server does its work it will call back to the client via that IDemoEvents interface.
If the callback function isn’t set, then it’s set to a dummy instance of DemoEvents, which just has empty methods. Thus the calls to “This.oCallback.SomeCallbackMethod” are just calls to empty code.
As another example, one can imagine that ADO was written in Foxpro (that’s not too far from the truth: ADO is based on the Fox engine).
DEFINE CLASS RecordSet as session OLEPUBLIC
oCallBack && initialize like the IDemo sample
PROCEDURE MoveNext
this.oCallBack.WillMoveNext()
< do the actual MoveNext>
this.oCallBack.MoveNextComplete(0
ENDDEFINE
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only