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 / guipaper.h < prev    next >
C/C++ Source or Header  |  1997-08-30  |  6KB  |  161 lines

  1. /*+==========================================================================
  2.   File:      GUIPAPER.H
  3.  
  4.   Summary:   Include file for the CGuiPaper C++ class. A GuiPaper is a C++
  5.              object that displays and stores mouse movements as free-form
  6.              line drawing or "scribbling" in the client area of a
  7.              designated window. GuiPaper is anchored to the Windows GUI
  8.              (Graphical User Interface) environment. This GuiPaper object
  9.              relies on a virtual Paper object that is instantiated as a
  10.              COM object (a COPaper) in a separate out-of-process server,
  11.              DCDSERVE, to store the "ink" data that is drawn.
  12.  
  13.              For a comprehensive tutorial code tour of GUIPAPER's contents
  14.              and offerings see the tutorial DCOMDRAW.HTM file. For
  15.              more specific technical details on the internal workings see
  16.              the comments dispersed throughout the GUIPAPER source code.
  17.  
  18.   Classes:   CGuiPaper.
  19.  
  20.   Origin:    8-23-97: atrent - Editor inheritance from GUIBALL.H in the
  21.              CONCLIEN source. [Revised]
  22. ----------------------------------------------------------------------------
  23.   This file is part of the Microsoft COM Tutorial Code Samples.
  24.  
  25.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  26.  
  27.   This source code is intended only as a supplement to Microsoft
  28.   Development Tools and/or on-line documentation.  See these other
  29.   materials for detailed information regarding Microsoft code samples.
  30.  
  31.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  32.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  33.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  34.   PARTICULAR PURPOSE.
  35. ==========================================================================+*/
  36.  
  37. #if !defined(GUIPAPER_H)
  38. #define GUIPAPER_H
  39.  
  40. #if defined(__cplusplus)
  41.  
  42.  
  43. /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
  44.   Class:    CGuiPaper
  45.  
  46.   Summary:  Class to encapsulate the displayable Graphical User Interface
  47.             GUI Paper object.
  48.  
  49.   Methods:  CGuiPaper
  50.               Constructor.
  51.             ~CGuiPaper
  52.               Destructor.
  53.             BOOL Init(HINSTANCE hInst, HWND hWnd);
  54.               Initialize the GuiPaper.
  55.             HRESULT SetPenCur(USHORT usPenCurNew);
  56.               Set the pen width and pen On/Off.
  57.             HRESULT Lock(BOOL bLock);
  58.               Lock or unlock paper for drawing. Master client has lock.
  59.             BOOL    Master(void);
  60.               Return TRUE if this client is the owning master client.
  61.             HRESULT ResizeWin(LONG lWidth, LONG lHeight);
  62.               Resize the display window.
  63.             HRESULT ClearWin(void);
  64.               Clear display window but retain ink data.
  65.             HRESULT PaintWin(void);
  66.               Clear window and Repaint the window with ink data.
  67.             HRESULT Erase(void);
  68.               Erase current drawn content and clear display window.
  69.             HRESULT Resize(LONG lWidth, LONG lHeight);
  70.               Resize the display rectangle of the drawing.
  71.             HRESULT InkWidth(SHORT nInkWidth);
  72.               Set current ink line width for drawing.
  73.             HRESULT InkColor(COLORREF crInkColor);
  74.               Set current ink color for drawing.
  75.             HRESULT InkStart(SHORT nX, SHORT nY);
  76.               Start ink drawing sequence.
  77.             HRESULT InkDraw(SHORT nX, SHORT nY);
  78.               Draw ink sequence data.
  79.             HRESULT InkStop(SHORT nX, SHORT nY);
  80.               Stop ink drawing sequence.
  81.             HRESULT ConnectPaperSink(void);
  82.               Connect the PaperSink to the server COPaper source.
  83.             HRESULT DisconnectPaperSink(void);
  84.               Disconnect the PaperSink from the server COPaper source.
  85.             HRESULT Load(void);
  86.               Load ink data from current compound file (local or remote).
  87.             HRESULT LoadLocal(void);
  88.               Unload current drawing and Load drawing from local
  89.               DCDSERVE server.
  90.             HRESULT LoadRemote(void);
  91.               Unload current drawing paper and reload from a DCDSERVE
  92.               located on a remote machine. User gives remote machine
  93.               name in a dialog.
  94.             HRESULT Save(void);
  95.               Save existing Ink Data to current compound file.
  96.             INT AskSave(void);
  97.               Check if new ink data, ask user, save if user says to.
  98.             COLORREF PickColor(void);
  99.               Common dialog. Ask user to choose new pen color.
  100. C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
  101. class CGuiPaper
  102. {
  103.   public:
  104.     CGuiPaper(void);
  105.     ~CGuiPaper(void);
  106.     BOOL Init(HINSTANCE hInst, HWND hWnd);
  107.     HRESULT SetPenCur(USHORT usPenCurNew);
  108.     HRESULT Lock(BOOL bLock);
  109.     BOOL    Master(void);
  110.     HRESULT ResizeWin(LONG lWidth, LONG lHeight);
  111.     HRESULT ClearWin(void);
  112.     HRESULT PaintWin(void);
  113.     HRESULT Erase(void);
  114.     HRESULT Resize(LONG lWidth, LONG lHeight);
  115.     HRESULT InkWidth(SHORT nInkWidth);
  116.     HRESULT InkColor(COLORREF crInkColor);
  117.     HRESULT InkStart(SHORT nX, SHORT nY);
  118.     HRESULT InkDraw(SHORT nX, SHORT nY);
  119.     HRESULT InkStop(SHORT nX, SHORT nY);
  120.     HRESULT ConnectPaperSink(void);
  121.     HRESULT DisconnectPaperSink(void);
  122.     HRESULT Load(void);
  123.     HRESULT LoadLocal(void);
  124.     HRESULT LoadRemote(void);
  125.     HRESULT Save(void);
  126.     INT     AskSave(void);
  127.     COLORREF PickColor(void);
  128.  
  129.   private:
  130.     HINSTANCE    m_hInst;
  131.     HWND         m_hWnd;
  132.     HDC          m_hDC;
  133.     RECT         m_WinRect;
  134.     ISharePaper* m_pISharePaper;
  135.     HPEN         m_hPen;
  136.     USHORT       m_PenCur;
  137.     HCURSOR      m_hPenCurN;
  138.     HCURSOR      m_hPenCurT;
  139.     HCURSOR      m_hPenCurM;
  140.     HCURSOR      m_hPenCurF;
  141.     SHORT        m_nInkWidth;
  142.     COLORREF     m_crInkColor;
  143.     BOOL         m_bLocked;
  144.     BOOL         m_bInkSaving;
  145.     BOOL         m_bInking;
  146.     BOOL         m_bPainting;
  147.     POINT        m_OldPos;
  148.     IUnknown*    m_pCOPaperSink;
  149.     DWORD        m_dwPaperSink;
  150.     BOOL         m_bDirty;
  151.     CHOOSECOLOR  m_ChooseColor;
  152.     COLORREF     m_acrCustColors[16];
  153.  
  154.     IConnectionPoint* GetConnectionPoint(REFIID riid);
  155. };
  156.  
  157.  
  158. #endif // __cplusplus
  159.  
  160. #endif
  161.