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: ResetContent()18 void ResetContent() { SendMsg(CB_RESETCONTENT, 0, 0); } AddString(LPCTSTR s)19 LRESULT AddString(LPCTSTR s) { return SendMsg(CB_ADDSTRING, 0, (LPARAM)s); } 20 #ifndef _UNICODE 21 LRESULT AddString(LPCWSTR s); 22 #endif SetCurSel(int index)23 LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, index, 0); } GetCurSel()24 int GetCurSel() { return (int)SendMsg(CB_GETCURSEL, 0, 0); } GetCount()25 int GetCount() { return (int)SendMsg(CB_GETCOUNT, 0, 0); } 26 GetLBTextLen(int index)27 LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, index, 0); } GetLBText(int index,LPTSTR s)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 SetItemData(int index,LPARAM lParam)34 LRESULT SetItemData(int index, LPARAM lParam) { return SendMsg(CB_SETITEMDATA, index, lParam); } GetItemData(int index)35 LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, index, 0); } 36 GetItemData_of_CurSel()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: SetUnicodeFormat(bool fUnicode)47 bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMsg(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); } 48 DeleteItem(int index)49 LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, index, 0); } InsertItem(COMBOBOXEXITEM * item)50 LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_INSERTITEM, 0, (LPARAM)item); } 51 #ifndef _UNICODE InsertItem(COMBOBOXEXITEMW * item)52 LRESULT InsertItem(COMBOBOXEXITEMW *item) { return SendMsg(CBEM_INSERTITEMW, 0, (LPARAM)item); } 53 #endif 54 SetItem(COMBOBOXEXITEM * item)55 LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_SETITEM, 0, (LPARAM)item); } SetExtendedStyle(DWORD exMask,DWORD exStyle)56 DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); } GetEditControl()57 HWND GetEditControl() { return (HWND)SendMsg(CBEM_GETEDITCONTROL, 0, 0); } SetImageList(HIMAGELIST imageList)58 HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMsg(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); } 59 }; 60 61 #endif 62 63 }} 64 65 #endif 66