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 / perclien / guitext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-05  |  5.9 KB  |  141 lines

  1. /*+==========================================================================
  2.   File:      GUITEXT.H
  3.  
  4.   Summary:   Include file for the CGuiText C++ class. A GuiText is a C++
  5.              object that encapsulates and displays edited text in a
  6.              separate window. The text is edited in a standard Win32
  7.              multi-line edit control which is a child window occupying
  8.              the entire client area of a separate window. The separate
  9.              window is based on APPUTIL's CVirWindow. CGuiText is derived
  10.              from CVirWindow and extends it.
  11.  
  12.              GuiText is anchored to the Windows GUI (Graphical User
  13.              Interface) environment. This GuiText object relies on a text
  14.              object that is instantiated as a COM object (a COTextPage) in
  15.              a separate In-process server, PERTEXT, to store the page's
  16.              text data.
  17.  
  18.              For a comprehensive tutorial code tour of GUITEXT's contents
  19.              and offerings see the tutorial PERCLIEN.HTM file. For
  20.              more specific technical details on the internal workings see
  21.              the comments dispersed throughout the GUITEXT source code.
  22.  
  23.   Classes:   CGuiText.
  24.  
  25.   Origin:    5-25-97: atrent - Editor inheritance from GUIPAPER.H in the
  26.              STOCLIEN source.
  27. ----------------------------------------------------------------------------
  28.   This file is part of the Microsoft COM Tutorial Code Samples.
  29.  
  30.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  31.  
  32.   This source code is intended only as a supplement to Microsoft
  33.   Development Tools and/or on-line documentation.  See these other
  34.   materials for detailed information regarding Microsoft code samples.
  35.  
  36.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  37.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  38.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  39.   PARTICULAR PURPOSE.
  40. ==========================================================================+*/
  41.  
  42.  
  43. #if !defined(GUITEXT_H)
  44. #define GUITEXT_H
  45.  
  46.  
  47. #if defined(__cplusplus)
  48.  
  49.  
  50. /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
  51.   Class:    CGuiText
  52.  
  53.   Summary:  Class to encapsulate the displayable Graphical User Interface
  54.             (GUI) for functioning text edit control objects in separate
  55.             windows. Such a window has its own menu and window procedure.
  56.             CGuiText is derived from APPUTIL's CVirWindow and thus
  57.             inherits all the features and benefits of CVirWindow.
  58.  
  59.   Methods:  CGuiText
  60.               Constructor.
  61.             ~CGuiText
  62.               Destructor.
  63.             HRESULT OpenWin(
  64.                       IStorage* pIStorage_Root,
  65.                       WCHAR* pwszPageTitle,
  66.                       WCHAR* pwszDataName);
  67.               Get CGuiText started. Create Window. Make subordinate objects.
  68.             HRESULT TopWin(void);
  69.               Bring the CGuiText window to the on-screen top.
  70.             HRESULT ResizeWin(WORD wWidth, WORD wHeight);
  71.               Resize the current CGuiText window. Pass to edit control too.
  72.             HRESULT Renumber(INT iPage);
  73.               Re-assign the current dynamic page number of this page.
  74.             HRESULT ReleasePage(void);
  75.               Release the root storage held by this text page.
  76.             HRESULT RestorePage(IStorage* pIStorage_Root);
  77.               Restore the root storage for a new compound file.
  78.             HRESULT Close();
  79.               Close this page & window.
  80.             HRESULT Save(void);
  81.               Use COTextPage's IPersistStreamInit to save the text page.
  82.             INT AskSave(void);
  83.               If text changed ask user if save. Save text user says yes.
  84.             HRESULT Delete(void);
  85.               Delete the stored text page. Close page if open in window.
  86. C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
  87. class CGuiText : public CVirWindow
  88. {
  89.   public:
  90.     // Constructor and Destructor override those in CVirWindow.
  91.     CGuiText(HINSTANCE hInst, HWND hWndApp, INT iPage);
  92.     ~CGuiText(void);
  93.  
  94.     // The public CGuiText methods that extend CVirWindow.
  95.     HRESULT OpenWin(
  96.               IStorage* pIStorage_Root,
  97.               WCHAR* pwszPageTitle,
  98.               WCHAR* pwszDataName);
  99.     HRESULT TopWin(void);
  100.     HRESULT ResizeWin(WORD wWidth, WORD wHeight);
  101.     HRESULT Renumber(INT iPage);
  102.     HRESULT ReleasePage(void);
  103.     HRESULT RestorePage(IStorage* pIStorage_Root);
  104.     HRESULT Close();
  105.     HRESULT Save(void);
  106.     INT     AskSave(void);
  107.     HRESULT Delete(void);
  108.  
  109.   protected:
  110.     LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
  111.  
  112.   private:
  113.     // Private methods.
  114.     HRESULT Clear(void);
  115.     HRESULT Load(void);
  116.     IConnectionPoint* GetConnectionPoint(REFIID riid);
  117.     HRESULT ConnectSink(void);
  118.     HRESULT DisconnectSink(void);
  119.     HRESULT InitEditMenu(HMENU hEditMenu);
  120.     LRESULT DoCommand(WPARAM wParam, LPARAM lParam);
  121.  
  122.     // Private data members.
  123.     HWND m_hWndApp;              // Handle of the parent app window.
  124.     RECT m_WinRect;              // GuiText Window position rectangle.
  125.     HWND m_hWndEdit;             // Text edit control window handle.
  126.     CTextWin* m_pTextWin;        // Text edit control window C++ object.
  127.     IStorage* m_pIStorage_Root;  // IStorage on the root storage.
  128.     ITextPage* m_pITextPage;     // ITextPage on the COTextPage COM object.
  129.     INT m_iPage;                 // Page Number of this text page.
  130.     CLSID m_CidTextPage;         // The Class ID for COTextPage objects.
  131.     WCHAR m_wszDataName[PAGE_NAME_SIZE]; // Page DataName.
  132.     IUnknown* m_pCOTextPageSink; // Interface to TextPageSink COM object.
  133.     DWORD m_dwTextPageSink;      // Sink connection key.
  134.     BOOL m_bChanged;             // Was textwin data changed?
  135. };
  136.  
  137.  
  138. #endif // __cplusplus
  139.  
  140. #endif // GUITEXT.H
  141.