Callbacks into to Dolphin from OLE

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Callbacks into to Dolphin from OLE

Costas Menico
How do I make a callback into Dolphin from an OLE server I built using
Visual Foxpro or VB? Assuming I pass to it an instance whose class has
a method called #updateEvent:with:with:

I have the following sample OLE code using VFP. I can call the methods
from Dolphin but, how would I make the OLE notify Dolphin of an
update. Is this  doable?

Thanks

Costas

*** Dolphin code***
*** self has a method called #updateEvent:with:with
*** which is supposed to be called back by the OLE.

myServer:=nil.
myServer:=IDispatch createObject: 'Test.Common'.
myServer invoke: 'changed' with: self.
"This should cause an #updateEvent:wity:with"
myServer invoke: 'startServer'.  


*** VFP Code ***
*** Inherits from Custom and
*** compiled as Multi-Use/ Multi threaded OLE server.
define class Common as Custom olepublic
        * Instance variable declarations
         global = 0
         dependent = .null.
       
        * Instance Methods
        function changed(aDependent as Variant) as void
                 * Save dependent object.
                * This would be a Dolphin object.
          this.dependent=aDependent
        endfunc
        function getGlobal() as Integer
                return this.global
        endfunc
        function  startServer() as void
                * Increment variable and notify dependents
                this.global=this.global+1
                * I would like to call Dolphin here
                this.dependent.updateEvent('CHANGED',this)
        endfunc
enddefine


Reply | Threaded
Open this post in threaded view
|

Re: Callbacks into to Dolphin from OLE

Bill Schwab
Costas,

> How do I make a callback into Dolphin from an OLE server I built using
> Visual Foxpro or VB? Assuming I pass to it an instance

Well sorta.  But, Smalltalk instances don't make direct sense to any other
language.  In fact, they aren't much help to a separate Dolphin image
without some IPC mechanism between them.  The most likely things you'd want
to do are to pass a callback function (see ExternalCallback in the Education
Centre) or to expose your Smalltalk object via a COM interface pointer; see
the newCOMer sample on my web site, as well as Ian's archives to get started
with using COM.

TCP sockets are another great way to get data from one place to another,
but, are probabably not what you want in this situation.


> whose class has
> a method called #updateEvent:with:with:
>
> I have the following sample OLE code using VFP. I can call the methods
> from Dolphin but, how would I make the OLE notify Dolphin of an
> update. Is this  doable?

It should be possible.  The component would have to accept either a callback
function, a "custom" interface pointer, or (I think) better yet, use COM
Connection Points to talk to your Dolphin app.  I'll yield to Blair on
recommending the best solution.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Callbacks into to Dolphin from OLE

Blair McGlashan
In reply to this post by Costas Menico
Costas

> How do I make a callback into Dolphin from an OLE server I built using
> Visual Foxpro or VB? Assuming I pass to it an instance whose class has
> a method called #updateEvent:with:with:
>
> I have the following sample OLE code using VFP. I can call the methods
> from Dolphin but, how would I make the OLE notify Dolphin of an
> update. Is this  doable?

Certainly it can be done - go into the ActiveX Control Browser, use Ctrl+N
to bring up the MS Calendar control, and click around a bit. You should see
a trace of the "events" that the control is firing. This is achieved using
ActiveX Connection Points, which are specifically designed for the
publication of events, and ideally you should be publishing events in this
way from your components rather than using the custom mechanism that you
describe. Connection Points are a little more complex in terms of
implementation, but will be supported directly by most ActiveX hosts (e.g.
VB, Dolphin, etc). I don't really know about FoxPro, but I would be
surprised if it didn't have a simple way to implement the standard COM event
mechanism on its COM server objects (VB certainly does).

Dolphin will connect automatically to the default event interface of OCXs
that it hosts, but if you want to do the same for non-visual controls then I
suggest referring to the newsgroup archives since this topic has come up
before. Search for AXEventSink, the class that Dolphin uses to receive
events from controls. AXEventSink translates any incoming Active-X events to
Dolphin's own SASE event system as used in the MVP framework and elsewhere.

Should you still want to implement your custom event mechanism (I recommend
you use Connection Points), then your easiest approach is to provide an
appropriate implementation of IDispatch that you can pass to your FoxPro
component. If you browse AXEventSink you will see that it is a subclass of
AXDispatchImpAbstract, which provides most of the implementation of
IDispatch. Basically you need to subclass AXDispatchImpAbstract and
implement the two subclass responsibility methods.

Regards

Blair