home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / dcomdraw / sink.h < prev   
C/C++ Source or Header  |  1997-08-30  |  5KB  |  145 lines

  1. /*+==========================================================================
  2.   File:      SINK.H
  3.  
  4.   Summary:   Include file for the COPaperSink COM object class.
  5.  
  6.              COPaperSink offers a main IUnknown interface and the custom
  7.              IPaperSink interface (outgoing connection events from COPaper
  8.              drawing paper objects). This multiple interface COM Object
  9.              Class is achieved via the technique of nested classes.  The
  10.              implementation of the IPaperSink interface is nested inside
  11.              of the COPaperSink Class.
  12.  
  13.              For a comprehensive tutorial code tour of this module's
  14.              contents and offerings see the tutorial SSOCLIEN.HTM
  15.              file. For more specific technical details on the internal
  16.              workings see the comments dispersed throughout the module's
  17.              source code.
  18.  
  19.   Functions: .
  20.  
  21.   Classes:   COPaperSink.
  22.  
  23.   Origin:    8-23-97: atrent - Editor-inheritance from BALL.H in the
  24.              CONSERVE Tutorial Code Sample. [Revised]
  25.  
  26. ----------------------------------------------------------------------------
  27.   This file is part of the Microsoft COM Tutorial Code Samples.
  28.  
  29.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  30.  
  31.   This source code is intended only as a supplement to Microsoft
  32.   Development Tools and/or on-line documentation.  See these other
  33.   materials for detailed information regarding Microsoft code samples.
  34.  
  35.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  36.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  37.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  38.   PARTICULAR PURPOSE.
  39. ==========================================================================+*/
  40.  
  41. #if !defined(SINK_H)
  42. #define SINK_H
  43.  
  44. #ifdef __cplusplus
  45.  
  46.  
  47. /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
  48.   ObjectClass: COPaperSink
  49.  
  50.   Summary:     The main Sink COM object class for COPaperSink COM objects.
  51.                COM objects of this class offer the IPaperSink sink
  52.                interface supporting various drawing paper events. The
  53.                mulitple interfaces on this COM object are constructed via
  54.                the nested interface classes technique.
  55.  
  56.   Interfaces:  IUnknown
  57.                  Standard interface providing COM object features.
  58.                IPaperSink
  59.                  Sink interface for Paper events.
  60.  
  61.   Aggregation: Yes, COPaperSink COM Objects are aggregatable by passing
  62.                a non-NULL pUnkOuter IUnknown pointer into the constructor.
  63. O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
  64. class COPaperSink : public IUnknown
  65. {
  66.   public:
  67.     // Main Object Constructor & Destructor.
  68.     COPaperSink(IUnknown* pUnkOuter, CGuiPaper* pGuiPaper);
  69.     ~COPaperSink(void);
  70.  
  71.     // IUnknown methods. Main object, non-delegating.
  72.     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  73.     STDMETHODIMP_(ULONG) AddRef(void);
  74.     STDMETHODIMP_(ULONG) Release(void);
  75.  
  76.   private:
  77.     // We declare nested class interface implementations here.
  78.  
  79.     class CImpIPaperSink : public IPaperSink
  80.     {
  81.       public:
  82.         // Interface Implementation Constructor & Destructor.
  83.         CImpIPaperSink(COPaperSink* pCO, IUnknown* pUnkOuter);
  84.         ~CImpIPaperSink(void);
  85.  
  86.         // IUnknown methods.
  87.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  88.         STDMETHODIMP_(ULONG) AddRef(void);
  89.         STDMETHODIMP_(ULONG) Release(void);
  90.  
  91.         // IPaperSink methods.
  92.         STDMETHODIMP         Locked(void);
  93.         STDMETHODIMP         Unlocked(void);
  94.         STDMETHODIMP         Loaded(void);
  95.         STDMETHODIMP         Saved(void);
  96.         STDMETHODIMP         InkStart(
  97.                                SHORT nX,
  98.                                SHORT nY,
  99.                                SHORT nWidth,
  100.                                COLORREF crInkColor);
  101.         STDMETHODIMP         InkDraw(
  102.                                SHORT nX,
  103.                                SHORT nY);
  104.         STDMETHODIMP         InkStop(
  105.                                SHORT nX,
  106.                                SHORT nY);
  107.         STDMETHODIMP         Erased(void);
  108.         STDMETHODIMP         Resized(LONG lWidth, LONG lHeight);
  109.  
  110.       private:
  111.         // Data private to this interface implementation of IPaper.
  112.         COPaperSink* m_pCO;          // Parent Object back pointer.
  113.         IUnknown*    m_pUnkOuter;    // Outer unknown for Delegation.
  114.     };
  115.  
  116.     // Make the otherwise private and nested IPaperSink interface
  117.     // implementation a friend to COM object instantiations of this
  118.     // COPaperSink COM object class.
  119.     friend CImpIPaperSink;
  120.  
  121.     // Private data of COPaperSink COM objects.
  122.  
  123.     // Nested IPaperSink implementation instantiation.  This IPaperSink
  124.     // interface is instantiated inside this COPaperSink object as a
  125.     // native interface.
  126.     CImpIPaperSink   m_ImpIPaperSink;
  127.  
  128.     // Main Object reference count.
  129.     ULONG            m_cRefs;
  130.  
  131.     // Outer unknown (aggregation delegation). Used when this COM object
  132.     // is being aggregated.
  133.     IUnknown*        m_pUnkOuter;
  134.  
  135.     // Pointer to the main object that can service the Sink events.
  136.     CGuiPaper*       m_pGuiPaper;
  137. };
  138.  
  139. typedef COPaperSink* PCOPaperSink;
  140.  
  141. #endif // __cplusplus
  142.  
  143.  
  144. #endif // SINK_H
  145.