home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 January / pcwk_01_1999.iso / Wtestowe / Vistdstd / Install / Data.Z / Addsink.H < prev    next >
C/C++ Source or Header  |  1996-11-27  |  3KB  |  120 lines

  1. /* ADDSINK.H - Interface for a Visio Advise Sink.
  2.  * Copyright (C) 1996 Visio Corporation. All rights reserved.
  3.  */
  4.  
  5. //    (1)    Write a callback function to receive event notifications from Visio.
  6. //
  7. //    (2)    Call CoCreateAddonSink to make an instance of an "Advise Sink" object.
  8. //
  9. //    (3)    Find the EventList object in the Visio Object Model from which you
  10. //        want to receive event notifications and call EventList::AddAdvise with
  11. //        the sink pointer as its VARIANT IUnknown * argument.
  12.  
  13.  
  14. //    See the sample code in "generic.cpp" for a concrete example.
  15.  
  16. //    Your callback function should match this prototype:
  17.  
  18. #ifndef _ADDSINK_H
  19. #define _ADDSINK_H
  20.  
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. typedef HRESULT (STDMETHODCALLTYPE VISEVENTPROC)(
  26.                         IUnknown FAR *,        // ipSink [assert]
  27.                         WORD,                // wEvent
  28.                         IUnknown FAR*,        // ipSource [don't assert]
  29.                          DWORD,                // dwEventID
  30.                          DWORD,                // dwEventSeq
  31.                          IUnknown FAR*,        // ipSubject [don't assert]
  32.                          VARIANT);            // eventExtra
  33.  
  34. typedef VISEVENTPROC *LPVISEVENTPROC;
  35.  
  36. HRESULT CoCreateAddonSink(LPVISEVENTPROC pCallback, IUnknown FAR * FAR *ppSink);
  37.  
  38. #ifdef __cplusplus
  39. }    //    end of extern "C"
  40. #endif
  41.  
  42.  
  43. /**************************************************************************
  44.  *+ CVisioAddonSink: Interface
  45.  */
  46.  
  47. #ifdef __cplusplus
  48.  
  49. class CVisioAddonSink : public IDispatch
  50. {
  51. public:
  52.     // IUnknown methods
  53.  
  54.     STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppv);
  55.     STDMETHOD_(ULONG, AddRef)(void);
  56.     STDMETHOD_(ULONG, Release)(void);
  57.  
  58.  
  59.     // IDispatch methods
  60.  
  61.     STDMETHOD(GetTypeInfoCount)(
  62.         UINT FAR* pctinfo);
  63.  
  64.     STDMETHOD(GetTypeInfo)( 
  65.         UINT itinfo,
  66.         LCID lcid,
  67.         ITypeInfo FAR* FAR* pptinfo);
  68.  
  69.     STDMETHOD(GetIDsOfNames)( 
  70.         REFIID riid,
  71.         LPOLESTR FAR* rgszNames,
  72.         UINT cNames,
  73.         LCID lcid,
  74.         DISPID FAR* rgdispid);
  75.  
  76.     STDMETHOD(Invoke)( 
  77.         DISPID dispidMember,
  78.         REFIID riid,
  79.         LCID lcid,
  80.         WORD wFlags,
  81.         DISPPARAMS FAR* pdispparams,
  82.         VARIANT FAR* pvarResult,
  83.         EXCEPINFO FAR* pexcepinfo,
  84.         UINT FAR* puArgErr);
  85.  
  86.  
  87.     // CVisioAddonSink method
  88.  
  89.     STDMETHOD(VisEventProc)(
  90.         WORD             wEvent,            // i: code of event that's firing.
  91.         IUnknown FAR*    ipSource,        // i: object that is firing event.
  92.         DWORD            dwEventID,        // i: id of event that is firing.
  93.         DWORD            dwSeq,            // i: sequence number of event.
  94.         IUnknown FAR*     ipSubject,        // i: subject of this event.
  95.         VARIANT            vExtraInfo);    // i: other info. Usually nothing.
  96.  
  97.  
  98. private:
  99.     //    Private destructor enforces "Release" as means of destruction:
  100.     virtual ~CVisioAddonSink();
  101.  
  102.     // Constructors without implementation -- prevents compiler from generating default versions:
  103.     CVisioAddonSink();
  104.     CVisioAddonSink(const CVisioAddonSink&);
  105.  
  106.     // Real constructor ONLY accessible through friend function CoCreateAddonSink.
  107.     friend HRESULT CoCreateAddonSink(LPVISEVENTPROC pCallback, IUnknown FAR * FAR *ppSink);
  108.     CVisioAddonSink(LPVISEVENTPROC pCallback);
  109.  
  110.  
  111.     //    Data members:
  112.     static ITypeInfo FAR* m_pInfo;    //    IDispatch methods fail gracefully if NULL
  113.     ULONG m_cRef;                    //    reference count
  114.     LPVISEVENTPROC m_pCallback;        //    function to call when VisEventProc gets called...
  115. };
  116.  
  117. #endif    //    __cplusplus
  118.  
  119. #endif    //    _ADDSINK_H
  120.