Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.0 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: flexlistbox.h
  3. //
  4. // Desc: Implements a list box control that can display a list of text strings,
  5. // each can be selected by mouse. The class CFlexListBox is derived from
  6. // CFlexWnd. It is used by the class CFlexComboBox when it needs to
  7. // expand to show the list of choices.
  8. //
  9. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  10. //-----------------------------------------------------------------------------
  11. #ifndef __FLEXLISTBOX_H__
  12. #define __FLEXLISTBOX_H__
  13. #include "flexscrollbar.h"
  14. #define FLBF_INTEGRALHEIGHT 0x00000001
  15. #define FLBF_DEFAULT (FLBF_INTEGRALHEIGHT)
  16. enum {
  17. FLBN_SEL,
  18. FLBN_FINALSEL,
  19. FLBN_CANCEL
  20. };
  21. struct FLEXLISTBOXCREATESTRUCT {
  22. DWORD dwSize;
  23. DWORD dwFlags;
  24. HWND hWndParent;
  25. HWND hWndNotify;
  26. BOOL bVisible;
  27. RECT rect;
  28. HFONT hFont;
  29. COLORREF rgbText, rgbBk, rgbSelText, rgbSelBk, rgbFill, rgbLine;
  30. int nSBWidth;
  31. };
  32. struct FLEXLISTBOXITEM {
  33. FLEXLISTBOXITEM() : pszText(NULL), nID(-1), pData(NULL), bSelected(FALSE) {}
  34. FLEXLISTBOXITEM(const FLEXLISTBOXITEM &i) {nID = i.nID; pData = i.pData; bSelected = i.bSelected; SetText(i.GetText());}
  35. ~FLEXLISTBOXITEM() {cleartext();}
  36. void SetText(LPCTSTR str) {cleartext(); pszText = _tcsdup(str);}
  37. LPCTSTR GetText() const {return pszText;}
  38. int nID;
  39. void *pData;
  40. BOOL bSelected;
  41. private:
  42. void cleartext() {if (pszText) free(pszText); pszText = NULL;}
  43. LPTSTR pszText; // allocated
  44. };
  45. class CFlexListBox : public CFlexWnd
  46. {
  47. public:
  48. CFlexListBox();
  49. ~CFlexListBox();
  50. // creation
  51. BOOL Create(FLEXLISTBOXCREATESTRUCT *);
  52. BOOL CreateForSingleSel(FLEXLISTBOXCREATESTRUCT *);
  53. // cosmetics
  54. void SetFont(HFONT hFont);
  55. void SetColors(COLORREF text, COLORREF bk, COLORREF seltext, COLORREF selbk, COLORREF fill, COLORREF line);
  56. // setup
  57. int AddString(LPCTSTR); // returns index
  58. // interaction
  59. void SelectAndShowSingleItem(int i, BOOL bScroll = TRUE);
  60. void SetSel(int i) {SelectAndShowSingleItem(i, FALSE);}
  61. void StartSel();
  62. LPCTSTR GetSelText();
  63. int GetSel();
  64. protected:
  65. virtual void OnPaint(HDC hDC);
  66. virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  67. virtual void OnWheel(POINT point, WPARAM wParam);
  68. private:
  69. HWND m_hWndNotify;
  70. CArray<FLEXLISTBOXITEM, FLEXLISTBOXITEM &> m_ItemArray;
  71. COLORREF m_rgbText, m_rgbBk, m_rgbSelText, m_rgbSelBk, m_rgbFill, m_rgbLine;
  72. HFONT m_hFont;
  73. int m_nSBWidth;
  74. int m_nTextHeight;
  75. DWORD m_dwFlags;
  76. int m_nSelItem;
  77. int m_nTopIndex;
  78. void Calc();
  79. void SetVertSB(BOOL);
  80. void SetVertSB();
  81. void SetSBValues();
  82. void InternalPaint(HDC hDC);
  83. void Notify(int code);
  84. POINT m_point;
  85. BOOL m_bOpenClick; // True when user click the combobox to open the listbox. False after that button up msg is processed.
  86. BOOL m_bCapture;
  87. BOOL m_bDragging;
  88. CFlexScrollBar m_VertSB;
  89. BOOL m_bVertSB;
  90. };
  91. CFlexListBox *CreateFlexListBox(FLEXLISTBOXCREATESTRUCT *pcs);
  92. #endif //__FLEXLISTBOX_H__