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 / guilist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-05  |  6.9 KB  |  186 lines

  1. /*+==========================================================================
  2.   File:      GUILIST.H
  3.  
  4.   Summary:   Include file for the CGuiList C++ class. A GuiList is a C++
  5.              object that encapsulates and displays a page list. The list
  6.              is held in a standard listbox control which is a child window
  7.              occupying the entire client area of PERCLIEN's main
  8.              application window.
  9.  
  10.              GuiList is anchored to the Windows GUI (Graphical User
  11.              Interface) environment. This GuiList object relies on a List
  12.              object that is instantiated as a COM object (a COPageList) in
  13.              a separate In-process server, PERSERVE, to store the page
  14.              list data.
  15.  
  16.              For a comprehensive tutorial code tour of GUILIST's contents
  17.              and offerings see the tutorial PERCLIEN.HTM file. For
  18.              more specific technical details on the internal workings see
  19.              the comments dispersed throughout the GUILIST source code.
  20.  
  21.   Classes:   CGuiList.
  22.  
  23.   Origin:    5-20-97: atrent - Editor inheritance from GUIPAPER.CPP in the
  24.              STOCLIEN source.
  25. ----------------------------------------------------------------------------
  26.   This file is part of the Microsoft COM Tutorial Code Samples.
  27.  
  28.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  29.  
  30.   This source code is intended only as a supplement to Microsoft
  31.   Development Tools and/or on-line documentation.  See these other
  32.   materials for detailed information regarding Microsoft code samples.
  33.  
  34.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  35.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  36.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  37.   PARTICULAR PURPOSE.
  38. ==========================================================================+*/
  39.  
  40.  
  41. #if !defined(GUILIST_H)
  42. #define GUILIST_H
  43.  
  44. #if defined(__cplusplus)
  45.  
  46. // PageList file extensions.
  47. #define PAG_EXT "PAG"
  48. #define PAG_FILE_EXT ".PAG"
  49.  
  50. // List display line format strings.
  51. #define PAGE_OPEN_STR "+"
  52. #define PAGE_CLOSED_STR "-"
  53. #define TYPE_TEXT_STR "T"
  54. #define TYPE_DRAWING_STR "D"
  55. #define TYPE_UNKNOWN_STR "?"
  56. #define PAGE_UNTITLED_STR "Untitled"
  57. #define LISTWIN_FMT_STR "%s %u %s: %s"
  58.  
  59. // Allocation sizes for the OpenList array.
  60. enum
  61. {
  62.   OPENLIST_SIZE = 31
  63. };
  64.  
  65. // The OpenList item structure.
  66. typedef struct _OPENITEM
  67. {
  68.   SHORT     nType;                       // Page Type.
  69.   INT       iPage;                       // Page Number.
  70.   void*     pGuiPage;                    // Page Gui C++ object.
  71. } OPENITEM;
  72.  
  73.  
  74. /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
  75.   Class:    CGuiList
  76.  
  77.   Summary:  Class to encapsulate the displayable Graphical User Interface
  78.             GUI List object. This List object uses the standard Win32
  79.             listbox control to display page items.
  80.  
  81.   Methods:  CGuiList
  82.               Constructor.
  83.             ~CGuiList
  84.               Destructor.
  85.             BOOL Init(HINSTANCE hInst, HWND hWnd, TCHAR* pszCmdLineFile);
  86.               Initialize the GuiList; create subordinate objects, etc.
  87.             HRESULT ConnectSink(void);
  88.               Connect the PageListSink to the server COPageList event source.
  89.             HRESULT DisconnectSink(void);
  90.               Disconnect the PageListSink from the server COPageList source.
  91.             HRESULT Resize(WORD wWidth, WORD wHeight);
  92.               Resize the display window.
  93.             HRESULT Show(INT iNewSel);
  94.               Show the content of the page list; put content in listbox.
  95.             HRESULT Load(void);
  96.               Load PageList Data from current compound file.
  97.             HRESULT Save(void);
  98.               Save existing PageList Data to current compound file.
  99.             INT AskSave(void);
  100.               Check if new PageList data, ask user, save if user says to.
  101.             HRESULT Close(void);
  102.               Close this page list window; file save & file close if needed.
  103.             HRESULT Open(void);
  104.               Common dialog. Open existing .PAG compound file. Load PageList.
  105.             HRESULT SaveAs(void);
  106.               Common dialog. Save current PageList Data in renamed file.
  107.             HRESULT New(void);
  108.               Common dialog. Create new empty page list and file.
  109.             HRESULT PageTitle(void);
  110.               Dialog box. Edit a new title for the currently select page.
  111.             HRESULT PageOpen(void);
  112.               Open and load currently selected page in separate window.
  113.             HRESULT PageAdd(SHORT nPageType);
  114.               Add new page to the page list, create new separate window.
  115.             HRESULT PageDelete(void);
  116.               Delete currently selected page. Close its window if needed.
  117.             HRESULT PageChanged(INT iPage);
  118.               Set page changed status for this page to TRUE.
  119.             HRESULT PageClosed(INT iPage);
  120.               Mark this page as closed in the dynamic open item array.
  121. C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/
  122. class CGuiList
  123. {
  124.   public:
  125.     CGuiList(void);
  126.     ~CGuiList(void);
  127.     BOOL    Init(HINSTANCE hInst, HWND hWnd, TCHAR* pszCmdLineFile);
  128.     HRESULT ConnectSink(void);
  129.     HRESULT DisconnectSink(void);
  130.     HRESULT Resize(WORD wWidth, WORD wHeight);
  131.     HRESULT Show(INT iNewSel);
  132.     HRESULT Load(void);
  133.     HRESULT Save(void);
  134.     INT     AskSave(void);
  135.     HRESULT Close(void);
  136.     HRESULT Open(void);
  137.     HRESULT SaveAs(void);
  138.     HRESULT New(void);
  139.     HRESULT PageTitle(void);
  140.     HRESULT PageOpen(void);
  141.     HRESULT PageAdd(SHORT nPageType);
  142.     HRESULT PageDelete(void);
  143.     HRESULT PageChanged(INT iPage);
  144.     HRESULT PageClosed(INT iPage);
  145.  
  146.   private:
  147.     // Private methods.
  148.     HRESULT GetOpenItem(
  149.               INT iPage,
  150.               SHORT* pnType,
  151.               PPVOID ppGuiPage,
  152.               BOOL* pAddOk);
  153.     HRESULT AddOpenItem(INT iPage, SHORT nType, void* pGuiPage);
  154.     HRESULT DeleteOpenItem(INT iPage);
  155.     HRESULT RenumOpenItems(INT iPage);
  156.     HRESULT CloseOpenItem(INT iPage);
  157.     HRESULT SaveOpenPages(void);
  158.     HRESULT CloseOpenPages(void);
  159.     HRESULT CloseTextPages(void);
  160.     HRESULT ReleaseOpenPages(void);
  161.     HRESULT RestoreOpenPages(IStorage* pIStorage_Root);
  162.     IConnectionPoint* GetConnectionPoint(REFIID riid);
  163.  
  164.     // Private data members.
  165.     HINSTANCE    m_hInst;
  166.     HWND         m_hWnd;
  167.     RECT         m_WinRect;
  168.     IPageList*   m_pIPageList;
  169.     OPENITEM     m_paOpenList[OPENLIST_SIZE];
  170.     CListWin*    m_pListWin;
  171.     IStorage*    m_pIStorage_Root;
  172.     CPageFile*   m_pPageFile;
  173.     OPENFILENAME m_ofnFile;
  174.     TCHAR        m_szFileFilter[MAX_PATH];
  175.     TCHAR        m_szFileName[MAX_PATH];
  176.     TCHAR        m_szFileTitle[MAX_PATH];
  177.     IUnknown*    m_pCOPageListSink;
  178.     DWORD        m_dwPageListSink;
  179.     BOOL         m_bChanged;
  180. };
  181.  
  182.  
  183. #endif // __cplusplus
  184.  
  185. #endif
  186.