📄 addsink.h
字号:
// ADDSINK.H - Definitions for client side of Visio Advise Sink.
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// <summary>
// This header file contains the prototype for the event call back
// function (VISEVENTPROC) along with the class definitions for VEventHandler
// and CVisioAddonSink.
// </summary>
//
#ifndef _ADDSINK_H
#define _ADDSINK_H
#if defined VADDON_TLB
using namespace Visio;
#else
#include "Visio.h" // IVisEventProc
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Match the new IVisEventProc signature verbatim except that the
// first param here is the sink object that is calling the callback
// proc. (An additional param over what's received in VisEventProc.)
//
typedef HRESULT (STDMETHODCALLTYPE VISEVENTPROC)(
/* [in] */ IUnknown* ipSink, // ipSink [assert]
/* [in] */ short nEventCode, // code of event that's firing.
/* [in] */ IDispatch* pSourceObj, // object that is firing event.
/* [in] */ long nEventID, // id of event that is firing.
/* [in] */ long nEventSeqNum, // sequence number of event.
/* [in] */ IDispatch* pSubjectObj, // subject of this event.
/* [in] */ VARIANT vMoreInfo, // other info.
/* [retval][out] */ VARIANT* pvResult); // return a value to Visio for query events.
typedef VISEVENTPROC *LPVISEVENTPROC;
HRESULT CoCreateAddonSink(LPVISEVENTPROC pCallback, IUnknown FAR* FAR* ppSink);
#ifdef __cplusplus
} // end of extern "C"
#endif
// VEventHandler - definition of interface for handling Visio events
//
// <summary>
// This abstract base class contains a single method through which event
// notification will take place. Inherit your C++ class from this Class if
// you want a C++ object context (a this pointer) when you get called by
// VisEventProc in response to a Visio event.
// </summary>
//
#ifdef __cplusplus
class VEventHandler
{
public:
// This signature for HandleVisioEvent matches the new IVisEventProc
// signature verbatim except that the first param here is the
// sink object that is calling the callback proc. (An additional param
// over what's received in VisEventProc.)
//
virtual HRESULT HandleVisioEvent(
/* [in] */ IUnknown* ipSink, // ipSink [assert]
/* [in] */ short nEventCode, // code of event that's firing.
/* [in] */ IDispatch* pSourceObj, // object that is firing event.
/* [in] */ long nEventID, // id of event that is firing.
/* [in] */ long nEventSeqNum, // sequence number of event.
/* [in] */ IDispatch* pSubjectObj, // subject of this event.
/* [in] */ VARIANT vMoreInfo, // other info.
/* [retval][out] */ VARIANT* pvResult // return a value to Visio
// for query events.
) = 0;
};
// CoCreateAddonSinkForHandler - create a sink object that uses VEventHandler
//
// <summary>
// This method creates a sink object that Visio can use for event
// notification. The notification is handled through the VEventHandler
// interface.
// </summary>
//
HRESULT CoCreateAddonSinkForHandler(
LPVISEVENTPROC pCallback,
VEventHandler* pHandler,
IUnknown FAR* FAR* ppSink);
// CVisioAddonSink - Sink class that Visio uses to notify about events
//
// <summary>
// This class implements the IVisEventProc event notification interface.
// Use this class when signing up for Visio events using the AddAdvise
// method.
// </summary>
//
class CVisioAddonSink : public IVisEventProc
{
public:
// IUnknown methods
STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppv);
STDMETHOD_(ULONG, AddRef)(void);
STDMETHOD_(ULONG, Release)(void);
// IDispatch methods
STDMETHOD(GetTypeInfoCount)(
UINT FAR* pctinfo);
STDMETHOD(GetTypeInfo)(
UINT itinfo,
LCID lcid,
ITypeInfo FAR* FAR* pptinfo);
STDMETHOD(GetIDsOfNames)(
REFIID riid,
LPOLESTR FAR* rgszNames,
UINT cNames,
LCID lcid,
DISPID FAR* rgdispid);
STDMETHOD(Invoke)(
DISPID dispidMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR* pdispparams,
VARIANT FAR* pvarResult,
EXCEPINFO FAR* pexcepinfo,
UINT FAR* puArgErr);
// IVisEventProc method
#if defined VADDON_TLB
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE raw_VisEventProc(
#else
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE VisEventProc(
#endif
/* [in] */ short nEventCode,
/* [in] */ IDispatch __RPC_FAR* pSourceObj,
/* [in] */ long nEventID,
/* [in] */ long nEventSeqNum,
/* [in] */ IDispatch __RPC_FAR* pSubjectObj,
/* [in] */ VARIANT vMoreInfo,
/* [retval][out] */ VARIANT __RPC_FAR* pvResult);
protected:
// CVisioAddonSink objects and derived objects must be created with
// a ref count and destroyed by a final Release. This is the reason
// behind having the CoCreate-style helper functions. Visio *WILL*
// unload VSL's first at shutdown time and then Release all outstanding
// event sinks. That's why it's important to call CVisioEvent::Delete
// at VSL unload time... That forces Visio to Release your sink
// objects while they're still viable.
// Constructor - should only be used for sub-classing purposes.
// Subclass should override VisEventProc. This constructor leaves
// both m_pCallback and m_pHandler NULL.
CVisioAddonSink();
// Protected destructor enforces Release as delete mechanism.
virtual ~CVisioAddonSink();
private:
// Unimplemented private copy constructor.
CVisioAddonSink(const CVisioAddonSink&);
// Other constructors ONLY accessible through friend functions.
friend HRESULT CoCreateAddonSink(
LPVISEVENTPROC pCallback,
IUnknown FAR* FAR* ppSink);
friend HRESULT CoCreateAddonSinkForHandler(
LPVISEVENTPROC pCallback,
VEventHandler* pHandler,
IUnknown FAR* FAR* ppSink);
CVisioAddonSink(LPVISEVENTPROC pCallback, VEventHandler* pHandler= NULL);
// Common initialization called only from constructors:
void CommonConstruct(
LPVISEVENTPROC pCallback= NULL,
VEventHandler* pHandler= NULL);
// Data members:
static ITypeInfo FAR* m_pInfo; // IDispatch methods fail gracefully if NULL
static ULONG m_cRefInfo; // reference count for m_pInfo
ULONG m_cRef; // reference count for class instance
LPVISEVENTPROC m_pCallback; // function to call when VisEventProc gets called...
VEventHandler *m_pHandler; // object to call when VisEventProc gets called...
};
#endif // __cplusplus
#endif // _ADDSINK_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -