home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / controls / xlist / xlistctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  5.0 KB  |  172 lines

  1. // xlistctl.h : Declaration of the CXlistCtrl OLE control class.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14.  
  15. ///////////////////////////////////////////////////////////////////////////
  16. // CItemData : See xlistctl.cpp for implementation.
  17.  
  18. class CItemData : public CObject
  19. {
  20. public:
  21.  
  22. // Constructor/destructor
  23.  
  24.     CItemData(const TCHAR *pstrText, LPFONTDISP lpFontDisp, LPPICTUREDISP lpPicDisp);
  25.     ~CItemData();
  26.  
  27.  // Implementation
  28.  
  29.     OLE_COLOR *GetBackColor();
  30.     void SetBackColor(OLE_COLOR *newValue);
  31.     OLE_COLOR *GetForeColor();
  32.     void SetForeColor(OLE_COLOR *newValue);
  33.     void GetText(LPTSTR buffer, short szBuffer);
  34.     void SetText(const TCHAR *newValue);
  35.     CFontHolder *GetFont();
  36.     void SetFont(LPFONTDISP newValue);
  37.     CPictureHolder *GetPicture();
  38.     void SetPicture(LPPICTUREDISP newValue);
  39.  
  40. protected:
  41.     OLE_COLOR *pBack;
  42.     OLE_COLOR *pFore;
  43.     CString *pText;
  44.     CFontHolder *pFontHolder;
  45.     CPictureHolder *pPicHolder;
  46. };
  47.  
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CXlistCtrl : See xlistctl.cpp for implementation.
  51.  
  52. class CXlistCtrl : public COleControl
  53. {
  54.     DECLARE_DYNCREATE(CXlistCtrl)
  55.  
  56. // Constructor
  57. public:
  58.     CXlistCtrl();
  59.  
  60. // Overrides
  61.  
  62.     // Drawing function
  63.     virtual void OnDraw(
  64.                 CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
  65.  
  66.     // Persistence
  67.     virtual void DoPropExchange(CPropExchange* pPX);
  68.  
  69.     // Reset control state
  70.     virtual void OnResetState();
  71.  
  72.     // Notification of extended object available
  73.     virtual void OnSetClientSite();
  74.  
  75. // Implementation
  76. public:
  77.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  78. protected:
  79.     ~CXlistCtrl();
  80.  
  81.     DECLARE_OLECREATE_EX(CXlistCtrl)    // Class factory and guid
  82.     DECLARE_OLETYPELIB(CXlistCtrl)      // GetTypeInfo
  83.     DECLARE_PROPPAGEIDS(CXlistCtrl)     // Property page IDs
  84.     DECLARE_OLECTLTYPE(CXlistCtrl)      // Type name and misc status
  85.  
  86.     // Subclassed control support
  87.     BOOL PreCreateWindow(CREATESTRUCT& cs);
  88.     BOOL IsSubclassedControl();
  89.     LRESULT OnOcmCommand(WPARAM wParam, LPARAM lParam);
  90.  
  91.     virtual void OnAmbientPropertyChange(DISPID dispid);
  92.  
  93.     LRESULT OnOcmDrawItem(WPARAM wParam, LPARAM lParam);
  94.     LRESULT OnOcmMeasureItem(WPARAM wParam, LPARAM lParam);
  95.  
  96.     virtual void AddItem(short nIndex, LPCTSTR lpstrText, LPFONTDISP lpFontDisp,
  97.         LPPICTUREDISP lpPicDisp);
  98.  
  99.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  100.     virtual void SelectItemBackColor(CItemData *pItemData, LPRECT rect, CDC *pdc);
  101.     virtual void DrawItemPicture(CItemData *pItemData, LPRECT rect, CDC *pdc);
  102.     virtual void DrawItemText(CItemData *pItemData, LPRECT rect, CDC *pdc);
  103.     virtual void SelectItemForeColor(CItemData *pItemData, CDC *pdc);
  104.     virtual CFont* SelectItemFont(CItemData *pItemData, CDC *pdc,
  105.         CFontHolder& fontHolder);
  106.  
  107.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMI);
  108.     virtual int GetItemTextHeight(CItemData *pItemData);
  109.     virtual int GetItemPictureHeight(CItemData *pItemData);
  110.  
  111.     virtual void UpdateItems();
  112.     virtual void UpdateDefHeight();
  113.  
  114. // Message maps
  115.     //{{AFX_MSG(CXlistCtrl)
  116.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  117.     //}}AFX_MSG
  118.     DECLARE_MESSAGE_MAP()
  119.  
  120. // Dispatch maps
  121.     //{{AFX_DISPATCH(CXlistCtrl)
  122.     BOOL m_invertFlag;
  123.     afx_msg void OnInvertFlagChanged();
  124.     afx_msg void RemoveItem(short nIndex);
  125.     afx_msg void Clear();
  126.     afx_msg void AddTextFontItem(short nIndex, LPCTSTR lpstrText, LPFONTDISP font);
  127.     afx_msg void AddTextItem(short nIndex, LPCTSTR lpstrText);
  128.     afx_msg void AddPicItem(short nIndex, LPPICTUREDISP pic);
  129.     afx_msg OLE_COLOR GetItemBackColor(short nIndex);
  130.     afx_msg void SetItemBackColor(short nIndex, OLE_COLOR newValue);
  131.     afx_msg OLE_COLOR GetItemForeColor(short nIndex);
  132.     afx_msg void SetItemForeColor(short nIndex, OLE_COLOR newValue);
  133.     afx_msg BSTR GetItemText(short nIndex);
  134.     afx_msg void SetItemText(short nIndex, LPCTSTR lpszNewValue);
  135.     afx_msg LPFONTDISP GetItemFont(short nIndex);
  136.     afx_msg void SetItemFont(short nIndex, LPFONTDISP newValue);
  137.     afx_msg LPPICTUREDISP GetItemPicture(short nIndex);
  138.     afx_msg void SetItemPicture(short nIndex, LPPICTUREDISP newValue);
  139.     //}}AFX_DISPATCH
  140.     DECLARE_DISPATCH_MAP()
  141.  
  142.     afx_msg void AboutBox();
  143.  
  144. // Event maps
  145.     //{{AFX_EVENT(CXlistCtrl)
  146.     //}}AFX_EVENT
  147.     DECLARE_EVENT_MAP()
  148.  
  149. // Dispatch and event IDs
  150. public:
  151.     enum {
  152.     //{{AFX_DISP_ID(CXlistCtrl)
  153.     dispidInvertFlag = 1L,
  154.     dispidItemBackColor = 7L,
  155.     dispidItemForeColor = 8L,
  156.     dispidItemText = 9L,
  157.     dispidItemFont = 10L,
  158.     dispidItemPicture = 11L,
  159.     dispidRemoveItem = 2L,
  160.     dispidClear = 3L,
  161.     dispidAddTextFontItem = 4L,
  162.     dispidAddTextItem = 5L,
  163.     dispidAddPicItem = 6L,
  164.     //}}AFX_DISP_ID
  165.     };
  166.  
  167. // Data members
  168. protected:
  169.     CObArray m_itemData;
  170.     short m_itemDefHeight;
  171. };
  172.