ComboBoxExt.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #pragma once
  2. // CComboBoxExt
  3. #include "BaseComboBox.h"
  4. #include "ImageEx.h"
  5. class CComboBoxExt : public CWnd
  6. {
  7. DECLARE_DYNAMIC(CComboBoxExt)
  8. private:
  9. class combobox : public CBaseComboBox
  10. {
  11. public:
  12. combobox(){};
  13. ~combobox(){};
  14. protected:
  15. LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  16. {
  17. return CComboBox::WindowProc(message, wParam, lParam);
  18. };
  19. };
  20. public:
  21. CComboBoxExt();
  22. virtual ~CComboBoxExt();
  23. CComboBox* GetCmbCtrl(){ return &m_combobox;}
  24. private:
  25. combobox m_combobox;
  26. protected:
  27. DWORD m_dwStyle, m_dwConfig;
  28. CFont m_font;
  29. CString m_lpszText, m_lpszIcon, m_lpszDefault;
  30. CRect m_rcClient, m_rcText, m_rcIcon, m_rcIconAction;
  31. CImageEx * m_pIcon;
  32. BOOL m_bError;
  33. ENUM_COMBOBOX_TYPE m_combo_type;
  34. public:
  35. BOOL GetValidate();
  36. void GetWindowText(CString& rString);
  37. void SetWindowText(CString rString);
  38. // ÖØÔØÔ­ÉúComboBoxº¯Êý
  39. public:
  40. void ResetContent();
  41. int AddString(LPCTSTR lpszString);
  42. int InsertString(int nIndex, LPCTSTR lpszString);
  43. int SetItemDataPtr(int nIndex, void* pData);
  44. void* GetItemDataPtr(int nIndex) const;
  45. int SetItemData(int nIndex, DWORD_PTR dwItemData);
  46. DWORD_PTR GetItemData(int nIndex);
  47. int GetCount() const;
  48. int GetCurSel() const;
  49. int SetCurSel(int nSelect);
  50. void ShowDropDown(BOOL bShowIt = TRUE);
  51. BOOL GetDroppedState() const;
  52. void Clear();
  53. private:
  54. void OnCbnSelchange();
  55. protected:
  56. DECLARE_MESSAGE_MAP()
  57. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  58. virtual void PreSubclassWindow();
  59. virtual BOOL InitComboBox();
  60. virtual void OnPaint(CDC *pDC){};
  61. public:
  62. virtual BOOL Create(
  63. CWnd* pParentWnd
  64. , UINT nID
  65. , CRect& rect
  66. , LPCTSTR lpszText = NULL
  67. , DWORD dwStyle = WS_VISIBLE
  68. , ENUM_COMBOBOX_TYPE combo_type = COMBOBOX_SELECT
  69. );
  70. virtual BOOL Create(
  71. CWnd* pParentWnd
  72. , UINT nID
  73. , CPoint& point
  74. , CSize& size
  75. , LPCTSTR lpszText = NULL
  76. , DWORD dwStyle = WS_VISIBLE
  77. , ENUM_COMBOBOX_TYPE combo_type = COMBOBOX_SELECT
  78. );
  79. afx_msg void OnPaint();
  80. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  81. };