Fire an Event, sink a event - Help! 
Author Message
 Fire an Event, sink a event - Help!

Help!! I've got an ATL COM simple object that fires an event, the interface
for it looks something like this:

 //  An outgoing interface for well segments
 dispinterface _WellSegmentEvents
 {
  properties:
  methods:
  [id(1), helpstring("method WellSegmentChanged")] void
WellSegmentChanged();
 };

And then the actual object that fires these events is here:

  coclass PipeSegment
 {
  [default] interface IPipeSegment;
  [default, source] interface _WellSegmentEvents;
  interface IWellSegment;
 };

 I also have a container that will hold a bunch of these PipeSegmnt objects
via an "Add" method that takes an IWellSegment interface,and stics them into
a vector.  The container then gives these interfaces back to the user via a
Segment(long index) method.  What I want to do is have the container handle
the events that are fired by well segments, so I tried inheriting from
IDispEventImpl, like this in the coclass of my container:

class ATL_NO_VTABLE CWellSegmentList :
 public CComObjectRootEx<CComSingleThreadModel>,
 public CComCoClass<CWellSegmentList, &CLSID_WellSegmentList>,
 public IDispatchImpl<IWellSegmentList, &IID_IWellSegmentList,
&LIBID_SEGMENTSLib>,
 public CProxy_WellSegmentListEvents< CWellSegmentList >,
 public IConnectionPointContainerImpl<CWellSegmentList>,
 //  Stuff for implementing events and stuff . . .
 public IDispEventImpl<1, CWellSegmentList, &DIID__WellSegmentEvents,
&LIBID_SEGMENTSLib, 1, 0 >
{
--snip--
//  Sink for incoming events . . .
BEGIN_SINK_MAP(CWellSegmentList)
 SINK_ENTRY_EX(1, DIID__WellSegmentEvents, 0x1, OnWellSegmentChanged)
END_SINK_MAP()

Quote:
};

Here's what happens when I add a segment to the container:

STDMETHODIMP CWellSegmentList::Add(IWellSegment *pSegment)
{
 //  Add the segment to the vector
 m_vector.push_back(pSegment);
 pSegment->AddRef();
 //  TODO - Is this correct??  Establish a connection to the well segment
event system
 DispEventAdvise(pSegment);
 //  Adios
 return S_OK;

Quote:
}

Later, I got an interface to one of the segments fro the container, and
changed one of its properties, which should cause the segment to fire a
changed event, that would be handled by the container.  I stepped through
the code up to the point where the list of connections in the CP interface
of the segment are iterated through, and the call Invoke is made on the
client.  There was exactly one entry in the connection list (my container,
so that's right), that the segment proxy found, then there's a call to a
function named GetFuncInfoFromId, which returns an HRESULT of "Library not
registered", and it exits prematurely before getting to the part where it
actually invokes the method of the IDispatch interface on the client.  I
don't know what I should do next, but I think there is something wrong wit
the way I am specializing the IDispEventImpl template.  anyone have any idea
what would cause the event handling mechanism inherited from IDispImpl to
fail so gracefully?  There is nothing tragic happening, no assertions or
access violations, but after the event gets fired by the segment, it just
goes away.  Just exitsbefore invoking anything.  Is this the correct
approach?  This may be a dumb question, but wheredo i verify the major and
minor version of the type library?  The version info block lists a file
version of 1, 0, 0, 1, I think, but I don't know which part is which, just
have a suspicion I am giving the wrong parameters to the template.

Thanks in advance for any advice,

Aaron



Tue, 29 Apr 2003 08:10:06 GMT  
 Fire an Event, sink a event - Help!
The first obvious step would be to verify that the type library is indeed
registered. The version number is not the one in the Version resource, it's
the one in the [version] attribute of the library statement in the IDL.
--
With best wishes,
    Igor Tandetnik



Quote:
> Help!! I've got an ATL COM simple object that fires an event, the
interface
> for it looks something like this:

>  //  An outgoing interface for well segments
>  dispinterface _WellSegmentEvents
>  {
>   properties:
>   methods:
>   [id(1), helpstring("method WellSegmentChanged")] void
> WellSegmentChanged();
>  };

> And then the actual object that fires these events is here:

>   coclass PipeSegment
>  {
>   [default] interface IPipeSegment;
>   [default, source] interface _WellSegmentEvents;
>   interface IWellSegment;
>  };

>  I also have a container that will hold a bunch of these PipeSegmnt
objects
> via an "Add" method that takes an IWellSegment interface,and stics them
into
> a vector.  The container then gives these interfaces back to the user via
a
> Segment(long index) method.  What I want to do is have the container
handle
> the events that are fired by well segments, so I tried inheriting from
> IDispEventImpl, like this in the coclass of my container:

> class ATL_NO_VTABLE CWellSegmentList :
>  public CComObjectRootEx<CComSingleThreadModel>,
>  public CComCoClass<CWellSegmentList, &CLSID_WellSegmentList>,
>  public IDispatchImpl<IWellSegmentList, &IID_IWellSegmentList,
> &LIBID_SEGMENTSLib>,
>  public CProxy_WellSegmentListEvents< CWellSegmentList >,
>  public IConnectionPointContainerImpl<CWellSegmentList>,
>  //  Stuff for implementing events and stuff . . .
>  public IDispEventImpl<1, CWellSegmentList, &DIID__WellSegmentEvents,
> &LIBID_SEGMENTSLib, 1, 0 >
> {
> --snip--
> //  Sink for incoming events . . .
> BEGIN_SINK_MAP(CWellSegmentList)
>  SINK_ENTRY_EX(1, DIID__WellSegmentEvents, 0x1, OnWellSegmentChanged)
> END_SINK_MAP()
> };

> Here's what happens when I add a segment to the container:

> STDMETHODIMP CWellSegmentList::Add(IWellSegment *pSegment)
> {
>  //  Add the segment to the vector
>  m_vector.push_back(pSegment);
>  pSegment->AddRef();
>  //  TODO - Is this correct??  Establish a connection to the well segment
> event system
>  DispEventAdvise(pSegment);
>  //  Adios
>  return S_OK;
> }

> Later, I got an interface to one of the segments fro the container, and
> changed one of its properties, which should cause the segment to fire a
> changed event, that would be handled by the container.  I stepped through
> the code up to the point where the list of connections in the CP interface
> of the segment are iterated through, and the call Invoke is made on the
> client.  There was exactly one entry in the connection list (my container,
> so that's right), that the segment proxy found, then there's a call to a
> function named GetFuncInfoFromId, which returns an HRESULT of "Library not
> registered", and it exits prematurely before getting to the part where it
> actually invokes the method of the IDispatch interface on the client.  I
> don't know what I should do next, but I think there is something wrong wit
> the way I am specializing the IDispEventImpl template.  anyone have any
idea
> what would cause the event handling mechanism inherited from IDispImpl to
> fail so gracefully?  There is nothing tragic happening, no assertions or
> access violations, but after the event gets fired by the segment, it just
> goes away.  Just exitsbefore invoking anything.  Is this the correct
> approach?  This may be a dumb question, but wheredo i verify the major and
> minor version of the type library?  The version info block lists a file
> version of 1, 0, 0, 1, I think, but I don't know which part is which, just
> have a suspicion I am giving the wrong parameters to the template.

> Thanks in advance for any advice,

> Aaron



Tue, 29 Apr 2003 03:00:00 GMT  
 Fire an Event, sink a event - Help!
I double checked the version info in the attributes of the library section,
which indicate the same as I had used.  I have ended up using the
IDispEventSimpleImpl instead, so it is working now, but I must have done
something wrong with the IDispEventImpl template. I was surprised to see
that both of these templates actually step through the same code to handle a
event, the only difference being that the simpleImpl template already has
function info for the event, but the IDispEventImpl has to dig it out of the
type library.

Thanks,

Aaron

Quote:
> The first obvious step would be to verify that the type library is indeed
> registered. The version number is not the one in the Version resource,
it's
> the one in the [version] attribute of the library statement in the IDL.
> --
> With best wishes,
>     Igor Tandetnik



> > Help!! I've got an ATL COM simple object that fires an event, the
> interface
> > for it looks something like this:

> >  //  An outgoing interface for well segments
> >  dispinterface _WellSegmentEvents
> >  {
> >   properties:
> >   methods:
> >   [id(1), helpstring("method WellSegmentChanged")] void
> > WellSegmentChanged();
> >  };

> > And then the actual object that fires these events is here:

> >   coclass PipeSegment
> >  {
> >   [default] interface IPipeSegment;
> >   [default, source] interface _WellSegmentEvents;
> >   interface IWellSegment;
> >  };

> >  I also have a container that will hold a bunch of these PipeSegmnt
> objects
> > via an "Add" method that takes an IWellSegment interface,and stics them
> into
> > a vector.  The container then gives these interfaces back to the user
via
> a
> > Segment(long index) method.  What I want to do is have the container
> handle
> > the events that are fired by well segments, so I tried inheriting from
> > IDispEventImpl, like this in the coclass of my container:

> > class ATL_NO_VTABLE CWellSegmentList :
> >  public CComObjectRootEx<CComSingleThreadModel>,
> >  public CComCoClass<CWellSegmentList, &CLSID_WellSegmentList>,
> >  public IDispatchImpl<IWellSegmentList, &IID_IWellSegmentList,
> > &LIBID_SEGMENTSLib>,
> >  public CProxy_WellSegmentListEvents< CWellSegmentList >,
> >  public IConnectionPointContainerImpl<CWellSegmentList>,
> >  //  Stuff for implementing events and stuff . . .
> >  public IDispEventImpl<1, CWellSegmentList, &DIID__WellSegmentEvents,
> > &LIBID_SEGMENTSLib, 1, 0 >
> > {
> > --snip--
> > //  Sink for incoming events . . .
> > BEGIN_SINK_MAP(CWellSegmentList)
> >  SINK_ENTRY_EX(1, DIID__WellSegmentEvents, 0x1, OnWellSegmentChanged)
> > END_SINK_MAP()
> > };

> > Here's what happens when I add a segment to the container:

> > STDMETHODIMP CWellSegmentList::Add(IWellSegment *pSegment)
> > {
> >  //  Add the segment to the vector
> >  m_vector.push_back(pSegment);
> >  pSegment->AddRef();
> >  //  TODO - Is this correct??  Establish a connection to the well
segment
> > event system
> >  DispEventAdvise(pSegment);
> >  //  Adios
> >  return S_OK;
> > }

> > Later, I got an interface to one of the segments fro the container, and
> > changed one of its properties, which should cause the segment to fire a
> > changed event, that would be handled by the container.  I stepped
through
> > the code up to the point where the list of connections in the CP
interface
> > of the segment are iterated through, and the call Invoke is made on the
> > client.  There was exactly one entry in the connection list (my
container,
> > so that's right), that the segment proxy found, then there's a call to a
> > function named GetFuncInfoFromId, which returns an HRESULT of "Library
not
> > registered", and it exits prematurely before getting to the part where
it
> > actually invokes the method of the IDispatch interface on the client.  I
> > don't know what I should do next, but I think there is something wrong
wit
> > the way I am specializing the IDispEventImpl template.  anyone have any
> idea
> > what would cause the event handling mechanism inherited from IDispImpl
to
> > fail so gracefully?  There is nothing tragic happening, no assertions or
> > access violations, but after the event gets fired by the segment, it
just
> > goes away.  Just exitsbefore invoking anything.  Is this the correct
> > approach?  This may be a dumb question, but wheredo i verify the major
and
> > minor version of the type library?  The version info block lists a file
> > version of 1, 0, 0, 1, I think, but I don't know which part is which,
just
> > have a suspicion I am giving the wrong parameters to the template.

> > Thanks in advance for any advice,

> > Aaron



Wed, 30 Apr 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ATL COM Component firing events into VBScript event sink

2. Connection Points - firing an event to a sink in another process

3. creating a sink in VC to handle events fired by VB Com Object

4. ATL DLL event sink with a VB ActiveX DLL event source

5. How to event sink to events in the same IDispatch derived class

6. Event Sink for a COM object which raises events - Proof of Concept

7. Event handle as private member stops event firing.

8. Event sinking is sinking me!!! :)

9. please help !!! - reciving events to a c++ sink

10. Event Sink - Help please

11. Event Sink - Help please

12. help firing event from thread

 

 
Powered by phpBB® Forum Software