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 / chap10 / edataobj / edataobj.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.0 KB  |  82 lines

  1. /*
  2.  * EDATAOBJ.H
  3.  * Data Object EXE Chapter 10
  4.  *
  5.  * Definitions, classes, and prototypes for an application that
  6.  * provides DataObject objects to any other object user.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #ifndef _EDATAOBJ_H_
  17. #define _EDATAOBJ_H_
  18.  
  19. #include "dataobj.h"
  20.  
  21.  
  22. //EDATAOBJ.CPP
  23. LRESULT APIENTRY DataObjectWndProc(HWND, UINT, WPARAM, LPARAM);
  24.  
  25.  
  26. class CApp
  27.     {
  28.     friend LRESULT APIENTRY DataObjectWndProc(HWND, UINT
  29.         , WPARAM, LPARAM);
  30.  
  31.     protected:
  32.         HINSTANCE       m_hInst;            //WinMain parameters
  33.         HINSTANCE       m_hInstPrev;
  34.         LPSTR           m_pszCmdLine;
  35.  
  36.         HWND            m_hWnd;             //Main window handle
  37.         BOOL            m_fInitialized;     //Did CoInitialize work?
  38.  
  39.         //We have multiple classes, one for each data size.
  40.         DWORD           m_rgdwRegCO[DOSIZE_CSIZES];
  41.         LPCLASSFACTORY  m_rgpIClassFactory[DOSIZE_CSIZES];
  42.  
  43.     public:
  44.         CApp(HINSTANCE, HINSTANCE, LPSTR, UINT);
  45.         ~CApp(void);
  46.         BOOL Init(void);
  47.     };
  48.  
  49.  
  50. typedef CApp *PAPP;
  51.  
  52.  
  53. void ObjectDestroyed(void);
  54.  
  55.  
  56. //This class factory object creates Data Objects.
  57.  
  58. class CDataObjectClassFactory : public IClassFactory
  59.     {
  60.     protected:
  61.         ULONG           m_cRef;
  62.         UINT            m_iSize;        //Data size for this class
  63.  
  64.     public:
  65.         CDataObjectClassFactory(UINT);
  66.         ~CDataObjectClassFactory(void);
  67.  
  68.         //IUnknown members
  69.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  70.         STDMETHODIMP_(ULONG) AddRef(void);
  71.         STDMETHODIMP_(ULONG) Release(void);
  72.  
  73.         //IClassFactory members
  74.         STDMETHODIMP         CreateInstance(LPUNKNOWN, REFIID
  75.                                  , PPVOID);
  76.         STDMETHODIMP         LockServer(BOOL);
  77.     };
  78.  
  79. typedef CDataObjectClassFactory *PCDataObjectClassFactory;
  80.  
  81. #endif //_EDATAOBJ_H_
  82.