Home | History | Annotate | Download | only in Control
      1 // Windows/Control/ComboBox.h
      2 
      3 #ifndef __WINDOWS_CONTROL_COMBOBOX_H
      4 #define __WINDOWS_CONTROL_COMBOBOX_H
      5 
      6 #include "../../Common/MyWindows.h"
      7 
      8 #include <commctrl.h>
      9 
     10 #include "../Window.h"
     11 
     12 namespace NWindows {
     13 namespace NControl {
     14 
     15 class CComboBox: public CWindow
     16 {
     17 public:
     18   void ResetContent() { SendMsg(CB_RESETCONTENT, 0, 0); }
     19   LRESULT AddString(LPCTSTR s) { return SendMsg(CB_ADDSTRING, 0, (LPARAM)s); }
     20   #ifndef _UNICODE
     21   LRESULT AddString(LPCWSTR s);
     22   #endif
     23   LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, index, 0); }
     24   int GetCurSel() { return (int)SendMsg(CB_GETCURSEL, 0, 0); }
     25   int GetCount() { return (int)SendMsg(CB_GETCOUNT, 0, 0); }
     26 
     27   LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, index, 0); }
     28   LRESULT GetLBText(int index, LPTSTR s) { return SendMsg(CB_GETLBTEXT, index, (LPARAM)s); }
     29   LRESULT GetLBText(int index, CSysString &s);
     30   #ifndef _UNICODE
     31   LRESULT GetLBText(int index, UString &s);
     32   #endif
     33 
     34   LRESULT SetItemData(int index, LPARAM lParam) { return SendMsg(CB_SETITEMDATA, index, lParam); }
     35   LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, index, 0); }
     36 
     37   LRESULT GetItemData_of_CurSel() { return GetItemData(GetCurSel()); }
     38 
     39   void ShowDropDown(bool show = true) { SendMsg(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0);  }
     40 };
     41 
     42 #ifndef UNDER_CE
     43 
     44 class CComboBoxEx: public CComboBox
     45 {
     46 public:
     47   bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMsg(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); }
     48 
     49   LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, index, 0); }
     50   LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_INSERTITEM, 0, (LPARAM)item); }
     51   #ifndef _UNICODE
     52   LRESULT InsertItem(COMBOBOXEXITEMW *item) { return SendMsg(CBEM_INSERTITEMW, 0, (LPARAM)item); }
     53   #endif
     54 
     55   LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_SETITEM, 0, (LPARAM)item); }
     56   DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); }
     57   HWND GetEditControl() { return (HWND)SendMsg(CBEM_GETEDITCONTROL, 0, 0); }
     58   HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMsg(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); }
     59 };
     60 
     61 #endif
     62 
     63 }}
     64 
     65 #endif
     66