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