
TeledyneLeCroy SASVScriptEngineObjectEvents
126 AutomationAPIforTeledyneLeCroySAS/SATAProtocolSuite
SASVScriptEngine Object Events
_IVScriptEngineEvents Interface
ToretrieveeventnotificationsfromtheTeledyneLeCroySAS/SATAProtocolSuite
applicationwhenaverificationscriptengineobjectisrunningthescript,youmust
implementthe_IVScriptEngineEventscallbackinterface. Sincethisinterfaceisadefault
sourceinterfacefortheSASVScriptEngineobject,thereisaverysimpleimplementation
fromlanguagessuchasVisualBasic,VBA,VBScript,andWSH.
Somescriptenginesimposerestrictionsonhandling eventsfrom“indirect”automation
objectsintypelessscriptlanguages(whenanautomationinterfacetotheobjectis
obtainedfromacallofsomemethod,ratherthanfromcreationfunction,suchas
CreateObject()inVBScript).TheSAS/SATAProtocolSuiteapplicationprovidesaspecial
COMclass,allowingreceivingandhandlingofnotificationsfromaVSEobjectevenin
scriptlanguagesnotsupportingeventhandlingfrom"indirect"objects.
Example
TheC++implementationusedintheexamplesbelowimplementsaneventsinkobjectby
derivingitfromIdispEventImpl,butnotspecifyingthetypeli braryasatemplate
argument.Instead,thetypelibraryanddefa ultsourceinterfacefortheobjectare
determinedusingAtlGetObjectSourceInterface().
ASINK_ENTRY()macroisusedforeacheventfromeachsourceinterfacethatistobe
handled:
Example
C++:
class CVSEngineSink : public
IDispEventImpl<IDC_SRCOBJ_VSE, CVSEngineSink >
{
public:
...
BEGIN_SINK_MAP(CVSEngineSink)
// Make sure the Event Handlers have __stdcall calling
convention.
SINK_ENTRY( IDC_SRCOBJ_VSE, 1, OnVScriptReportUpdated )
SINK_ENTRY( IDC_SRCOBJ_VSE, 2, OnVScriptFinished )
SINK_ENTRY( IDC_SRCOBJ_VSE, 3, OnNotifyClient )
END_SINK_MAP()
HRESULT __stdcall OnVScriptReportUpdated ( BSTR
newLine, int TAG );
HRESULT __stdcall OnVScriptFinished( BSTR script_name,
VS_RESULT result,
int TAG );
HRESULT __stdcall OnNotifyClient (int eventId, VARIANT
eventBody, int TAG);
Comentarios a estos manuales