home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / common / msdev98 / bin / ide / devgal.pkg / TEMPLATE / 22327 < prev    next >
Encoding:
Text File  |  1998-06-18  |  3.0 KB  |  88 lines

  1. // $$VAL:HeaderFile$$ : header file
  2. //
  3.  
  4. #ifndef $$VAL:WrapHeader$$
  5. #define $$VAL:WrapHeader$$
  6.  
  7. // This class handles an owner-draw list box.  The list box in question
  8. // handles color bars instead of text.  It shows all of the required
  9. // features for an owner-draw list box. See the on-line help for CListBox 
  10. // for other ways you can manipulate the contents of an owner-draw list
  11. // box.
  12. //
  13. // You can actually handle just about anything you want in an owner-draw 
  14. // list box as long as you override functions CompareItem, DrawItem, and 
  15. // MeasureItem.  Strings are easiest and don't require all the overrides.  
  16. // Other examples: bitmaps, text in varying fonts, text in a non-standard 
  17. // font, etc.
  18. //
  19. // TODO:
  20. //    1.    Create an owner-draw list box in your resources to use with
  21. //        this class.  You will need to have the following features set
  22. //        on the Styles page for the list box:
  23. //        - Owner-Draw: Variable
  24. //        - Has Strings: Unchecked
  25. //        - Sort: Checked (to show off owner-draw sorting)
  26. //
  27. //    2.    Subclass your owner-draw list box to associate it with this
  28. //        class.  The following statement placed in OnInitDialog() for 
  29. //        the dialog you used this list box in should work fine:
  30. //            m_myDraw.SubclassDlgItem(IDC_MYDRAW, this);
  31. //        where:
  32. //            m_myDraw is an instance of the owner-draw list box class
  33. //            IDC_MYDRAW is the ID associated with your list box resource
  34. //
  35. //    3.    Call m_myDraw.LoadList() to initialize the contents of the owner-draw
  36. //        list box.  Do this immediately after you subclass the list box
  37. //        control.
  38. //
  39. //    4.    The list box implemented here is single selection for simplicity.  
  40. //        If you want    something different (like multiple or extended selection),
  41. //        you will need to do the following:
  42. //        - change the Selections type on the Styles page for the list box 
  43. //            appropriately
  44. //        - use the multiple-selection operations functions provided for 
  45. //            CListBox to manipulate the selections (see the on-line help 
  46. //            for CListBox for more details on these functions)
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // $$VAL:ClassName$$ window
  50.  
  51. class $$VAL:ClassName$$ : public CListBox
  52. {
  53. // Construction
  54. public:
  55.     $$VAL:ClassName$$();
  56.  
  57. // Attributes
  58. public:
  59.  
  60. // Operations
  61. public:
  62.     void AddListItem(COLORREF color);
  63.     void LoadList();
  64.  
  65. // Overrides
  66.     // ClassWizard generated virtual function overrides
  67.     //{{AFX_VIRTUAL($$VAL:ClassName$$)
  68.     public:
  69.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  70.     virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
  71.     virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
  72.     //}}AFX_VIRTUAL
  73.  
  74. // Implementation
  75. public:
  76.     virtual ~$$VAL:ClassName$$();
  77.  
  78.     // Generated message map functions
  79. protected:
  80.     //{{AFX_MSG($$VAL:ClassName$$)
  81.         // NOTE - the ClassWizard will add and remove member functions here.
  82.     //}}AFX_MSG
  83.  
  84.     DECLARE_MESSAGE_MAP()
  85. };
  86.  
  87. #endif $$VAL:WrapHeader$$    // end define of $$VAL:ClassName$$
  88.