Message 1 of 1
Problems sinking PartEvents, AssemblyEvents in C++

Not applicable
12-15-2004
12:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I know these seem to work OK in VB. I have had little problem with the ApplicationEvents, DocEvents etc sinks. However, the PartEvents and AssemblyEvents are defined to be IUnknown pointers. When I use code like this, cannot get to work:
// get the assy events object
CComQIPtr pAssyDoc (pDoc);
CComPtr pAssyCompDef;
CComPtr pUnk;
Result = pAssyDoc->get_ComponentDefinition (&pAssyCompDef);
if (FAILED (Result) || !pAssyCompDef)
return Result;
pAssyCompDef->get_AssemblyEvents (&pUnk);
// create the assy events handler
CComObject*pAssyEventsHdlr;
Result= CComObject::CreateInstance (&pAssyEventsHdlr);
if (FAILED (Result) || !pAssyEventsHdlr)
return Result;
// advise
Result = pAssyEventsHdlr->DispEventAdvise (pUnk);
I know this looks wierd and I'm not suprised it doesn't successfully sink the events. However, I have looked at all the help and samples (and google) and can find no help.
If anyone has been successful, please post a C++ way to connect to these events.
Any advice appreciated...
// get the assy events object
CComQIPtr
CComPtr
CComPtr
Result = pAssyDoc->get_ComponentDefinition (&pAssyCompDef);
if (FAILED (Result) || !pAssyCompDef)
return Result;
pAssyCompDef->get_AssemblyEvents (&pUnk);
// create the assy events handler
CComObject
Result= CComObject
if (FAILED (Result) || !pAssyEventsHdlr)
return Result;
// advise
Result = pAssyEventsHdlr->DispEventAdvise (pUnk);
I know this looks wierd and I'm not suprised it doesn't successfully sink the events. However, I have looked at all the help and samples (and google) and can find no help.
If anyone has been successful, please post a C++ way to connect to these events.
Any advice appreciated...