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 / chap02 / query / object3.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  2KB  |  60 lines

  1. /*
  2.  * OBJECT3.H
  3.  *
  4.  * Definition of the CObject1 class that uses mutliple
  5.  * inheritance to provide ISampleOne and ISampleTwo.
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13.  
  14.  
  15. #ifndef _OBJECT3_H_
  16. #define _OBJECT3_H_
  17.  
  18.  
  19. //Creation function
  20. BOOL CreateObject3(IUnknown **);
  21.  
  22.  
  23. /*
  24.  * The object we want to provide in OLE supports the IUnknown,
  25.  * ISampleOne, and ISampleTwo interfaces.
  26.  *
  27.  * The C++ class, CObject3, implements these interfaces through
  28.  * multiple inheritance, so the implementation of all IUnknown
  29.  * members is shared.  The trick to this implementation is that
  30.  * we have to use explicit typecasts in the implementation of
  31.  * QueryInterface in order to create the right vtables for each
  32.  * interface.  See OBJECT3.CPP.
  33.  */
  34.  
  35. //The C++ class that manages the actual object.
  36. class CObject3 : public ISampleOne, public ISampleTwo
  37.     {
  38.     private:
  39.         DWORD           m_cRef;         //Object reference count
  40.  
  41.     public:
  42.         CObject3(void);
  43.         ~CObject3(void);
  44.  
  45.         //Shared IUnknown members
  46.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  47.         STDMETHODIMP_(DWORD) AddRef(void);
  48.         STDMETHODIMP_(DWORD) Release(void);
  49.  
  50.         //ISampleOne members
  51.         STDMETHODIMP         GetMessage(LPTSTR, UINT);
  52.  
  53.         //ISampleTwo members
  54.         STDMETHODIMP         GetString(LPTSTR, UINT);
  55.     };
  56.  
  57. typedef CObject3 *PCObject3;
  58.  
  59. #endif _OBJECT3_H_
  60.