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 10namespace NWindows { 11namespace NControl { 12 13class CComboBox: public CWindow 14{ 15public: 16 void ResetContent() { SendMessage(CB_RESETCONTENT, 0, 0); } 17 LRESULT AddString(LPCTSTR s) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)s); } 18 #ifndef _UNICODE 19 LRESULT AddString(LPCWSTR s); 20 #endif 21 LRESULT SetCurSel(int index) { return SendMessage(CB_SETCURSEL, index, 0); } 22 int GetCurSel() { return (int)SendMessage(CB_GETCURSEL, 0, 0); } 23 int GetCount() { return (int)SendMessage(CB_GETCOUNT, 0, 0); } 24 25 LRESULT GetLBTextLen(int index) { return SendMessage(CB_GETLBTEXTLEN, index, 0); } 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 32 LRESULT SetItemData(int index, LPARAM lParam) { return SendMessage(CB_SETITEMDATA, index, lParam); } 33 LRESULT GetItemData(int index) { return SendMessage(CB_GETITEMDATA, index, 0); } 34 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 42class CComboBoxEx: public CComboBox 43{ 44public: 45 bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMessage(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); } 46 47 LRESULT DeleteItem(int index) { return SendMessage(CBEM_DELETEITEM, index, 0); } 48 LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); } 49 #ifndef _UNICODE 50 LRESULT InsertItem(COMBOBOXEXITEMW *item) { return SendMessage(CBEM_INSERTITEMW, 0, (LPARAM)item); } 51 #endif 52 53 LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMessage(CBEM_SETITEM, 0, (LPARAM)item); } 54 DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMessage(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); } 55 HWND GetEditControl() { return (HWND)SendMessage(CBEM_GETEDITCONTROL, 0, 0); } 56 HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); } 57}; 58 59#endif 60 61}} 62 63#endif 64