1 ianalyzerevents dispinterface, Ianalyzerevents dispinterface – Teledyne LeCroy FireInspector Automation Application Programming Interface User Manual

Page 70

Advertising
background image

66

FireInspector Automation User’s Manual

CATC

Version 1.0

2.7.1

IAnalyzerEvents dispinterface

In order to retrieve the events from FireInspector application you must implement

_IAnalyzerEvents

interface.

Since this interface is default source interface for

FwAnalyzer

object there is very simple

implementation from languages such as Visual Basic, VBA, VBScript, WSH etc.

C++ implementation used in the examples below utilizes a sink object by deriving from

IDispEventImpl

but not specifying the type library as a template argument. Instead,

the type library and default source interface for the object are determined using

AtlGe-

tObjectSourceInterface()

. A

SINK_ENTRY()

macro is used for each event

from each source interface which is to be handled:

class CAnalyzerSink : public IDispEventImpl<IDC_SRCOBJ,

CAnalyzerSink>

{

BEGIN_SINK_MAP(CAnalyzerSink)

//Make sure the Event Handlers have __stdcall calling

convention

SINK_ENTRY(IDC_SRCOBJ, 1, OnTraceCreated)

SINK_ENTRY(IDC_SRCOBJ, 2, OnStatusReport)

END_SINK_MAP()

. . .

}

Then, after you established the connection with server you need to advise your implemen-
tation of the event interface:

hr = CoCreateInstance( CLSID_FwAnalyzer, NULL,

CLSCTX_SERVER, IID_IFwAnalyzer, (LPVOID *)&m_poFwAnalyzer

);

m_poAnalyzerSink = new CAnalyzerSink();

// Make sure the COM object corresponding to pUnk implements

// IProvideClassInfo2 or IPersist*. Call this method to

extract info about

// source type library if you specified only 2 parameters to

IDispEventImpl

hr =

AtlGetObjectSourceInterface(m_poFwAnalyzer,&m_poAnalyzerSink

->m_libid,

&m_poAnalyzerSink->m_iid,

&m_poAnalyzerSink->m_wMajorVerNum,

&m_poAnalyzerSink->m_wMinorVerNum);

if ( FAILED(hr) )

return 1;

// connect the sink and source, m_poFwAnalyzer is the source

COM object

hr = m_poAnalyzerSink->DispEventAdvise(m_poFwAnalyzer,

&m_poAnalyzerSink->m_iid);

if ( FAILED(hr) )

return 1;

Advertising