Re: getting an event handler from a active-x dll dispinterface



Thanks to your reply I was able to solve it. It gave me the idea that
essentially I was doing the right thing but there was a detail going
wrong.
The detail was that in the connect method I had to typecast the
com-object parameter to its parent class.

(But still the event object connects to the com-object in stead of the
other way around.)


On Tue, 26 Dec 2006 10:46:51 +0100, "Maarten Wiltink"
<maarten@xxxxxxxxxxxxxxxxxx> wrote:

"HanslH" <no@xxxxx> wrote in message
news:v7i0p2p9c28ilh3rtce3mpu0jedir0o5mk@xxxxxxxxxx

I used EventSinkImp to create a component based on the event-object.
The component is only very simple, it just has the youhaveamessage
event and name and tag property in the object inspector.

Why a TComponent? Any object would do.


The event is not fired on incoming messages when i create an object
(which is logical since not even a port is opened or whatever).
The other class of which I did succesfully create an communication
object does have an openport, sendmessage,getmessage function. So one
way or the other I have to connect the two.
The event object-class has a connect method:
Connect (const ASource: IUnknown);

I don't know what an IUnkNown is

It's the TObject of interfaces, from which all other ones derive.
It allows having a single Connect method. The receiving object will
check that the interface supplied is of the right type, and only
fire events through it if it is.

Some strong type-checking is lost there, as you've found out.


but if I use the (connected and functioning) communcation object
as a parameter it does compile, it does run but it doesn't fire
events.

Calling a method on the event sink object to connect the source?
Odd. I would have expected the source (the communication object)
to have a method to pass the event sink object('s interface) to.


I know i display utter ignorance here. I don't want to become an
activeX expert.

No, you don't. I know too much about it for my own happiness.

Groetjes,
Maarten Wiltink

.



Relevant Pages

  • Re: getting an event handler from a active-x dll dispinterface
    ... Connect (const ASource: IUnknown); ... fire events through it if it is. ... Calling a method on the event sink object to connect the source? ... to have a method to pass the event sink object('s interface) to. ...
    (alt.comp.lang.borland-delphi)
  • Marshalling a marshalled interface pointer
    ... component that contains this object holds a container of IUnknown ... It also exposes the interface 'IDiscussions' which provides the method ... Another 'ChatServer' is started and registers itself with the ... ChatBroker with the name "Server2". ...
    (microsoft.public.vc.atl)
  • Re: IUnknown interface
    ... both directly derived from IUnknown. ... two different implementations (note that usually both interface tables ... ULONG STDMETHODCALLTYPE Release ... virtual HRESULT DoSomething ...
    (microsoft.public.vc.language)
  • Re: Dual interface
    ... and exposes IDispatch (it must expose IUnknown ... I think the law should be every interface of the COM component implements, ... If a component implements a customized interface, ... then we could invoke the ...
    (microsoft.public.vc.language)
  • Re: ATL and object aggregation (more)
    ... I don't think you should call Releaseon an interface's pointer. ... an helper method that is called by the 'true' COM interface method ... > It's wrong because the IUnknown interface will be lost during the Query ... then the IInObj3Ptr InObj3Ptr constructor is ...
    (microsoft.public.vc.atl)