home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / chap14 / beeper4 / beeper.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  3.6 KB  |  140 lines

  1. /*
  2.  * BEEPER.H
  3.  * Beeper Automation Object #4 Chapter 14
  4.  *
  5.  * Classes that implement the Beeper object.
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Right Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13.  
  14.  
  15. #ifndef _BEEPER_H_
  16. #define _BEEPER_H_
  17.  
  18. /*
  19.  * This #define tells <bookguid.h> to not define GUIDs that will
  20.  * be defined in MKTYPLIB-generated header files, like ibeeper.h.
  21.  */
  22. #define GUIDS_FROM_TYPELIB
  23. #define INC_AUTOMATION
  24. #define CHAPTER14
  25. #include <inole.h>
  26. #include <malloc.h>
  27.  
  28. //This file is generated from MKTYPLIB
  29. #include "ibeeper.h"
  30.  
  31. //This one isn't defined in ibeeper.h
  32. DEFINE_GUID(DIID_DIBeeper,0x0002115D,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
  33.  
  34. //Help context ID for exceptions
  35. #define HID_SOUND_PROPERTY_LIMITATIONS  0x1E100
  36.  
  37. //English exception strings
  38. #define IDS_0_MIN                   16
  39. #define IDS_0_EXCEPTIONSOURCE       (IDS_0_MIN)
  40. #define IDS_0_EXCEPTIONINVALIDSOUND (IDS_0_MIN+1)
  41.  
  42. //German exception strings
  43. #define IDS_7_MIN                   32
  44. #define IDS_7_EXCEPTIONSOURCE       (IDS_7_MIN)
  45. #define IDS_7_EXCEPTIONINVALIDSOUND (IDS_7_MIN+1)
  46.  
  47.  
  48. //Forward class declarations for friend statements
  49. class CImpISupportErrorInfo;
  50. typedef CImpISupportErrorInfo *PCImpISupportErrorInfo;
  51.  
  52. class CBeeper : public IBeeper
  53.     {
  54.     protected:
  55.         ULONG           m_cRef;             //Object reference count
  56.         LPUNKNOWN       m_pUnkOuter;        //Controlling unknown
  57.         PFNDESTROYED    m_pfnDestroy;       //To call on closure
  58.  
  59.         long            m_lSound;
  60.  
  61.         //Our interfaces
  62.         PCImpISupportErrorInfo m_pImpISuppErr;
  63.  
  64.         ITypeInfo      *m_pITINeutral;      //Type information
  65.         ITypeInfo      *m_pITIGerman;
  66.  
  67.     public:
  68.         CBeeper(LPUNKNOWN, PFNDESTROYED);
  69.         ~CBeeper(void);
  70.  
  71.         BOOL         Init(void);
  72.         void         Exception(WORD);
  73.  
  74.         //Non-delegating object IUnknown
  75.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  76.         STDMETHODIMP_(ULONG) AddRef(void);
  77.         STDMETHODIMP_(ULONG) Release(void);
  78.  
  79.         //IDispatch members
  80.         STDMETHODIMP GetTypeInfoCount(UINT *);
  81.         STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **);
  82.         STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID
  83.             , DISPID *);
  84.         STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD
  85.             , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
  86.  
  87.         //IBeeper functions
  88.         STDMETHODIMP get_Sound(long *);
  89.         STDMETHODIMP put_Sound(long);
  90.         STDMETHODIMP Beep(long *);
  91.     };
  92.  
  93. typedef CBeeper *PCBeeper;
  94.  
  95.  
  96. //DISPIDs for our dispinterface
  97. enum
  98.     {
  99.     PROPERTY_SOUND=0,
  100.     METHOD_BEEP
  101.     };
  102.  
  103.  
  104. //Exceptions we can throw from IDispatch::Invoke
  105. enum
  106.     {
  107.     EXCEPTION_NONE=0,
  108.     EXCEPTION_INVALIDSOUND=1000
  109.     };
  110.  
  111.  
  112. /*
  113.  * ISupportErrorInfo interface implementations for the Beeper.
  114.  */
  115.  
  116. class CImpISupportErrorInfo : public ISupportErrorInfo
  117.     {
  118.     public:
  119.         ULONG           m_cRef;     //For debugging
  120.  
  121.     private:
  122.         PCBeeper        m_pObj;
  123.         LPUNKNOWN       m_pUnkOuter;
  124.  
  125.     public:
  126.         CImpISupportErrorInfo(PCBeeper, LPUNKNOWN);
  127.         ~CImpISupportErrorInfo(void);
  128.  
  129.         //IUnknown members that delegate to m_pUnkOuter.
  130.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  131.         STDMETHODIMP_(ULONG) AddRef(void);
  132.         STDMETHODIMP_(ULONG) Release(void);
  133.  
  134.         //ISupportErrorInfo members
  135.         STDMETHODIMP InterfaceSupportsErrorInfo(REFIID);
  136.     };
  137.  
  138.  
  139. #endif //_BEEPER_H_
  140.