1370b324cSopenharmony_ci// Windows/Control/ComboBox.h 2370b324cSopenharmony_ci 3370b324cSopenharmony_ci#ifndef ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H 4370b324cSopenharmony_ci#define ZIP7_INC_WINDOWS_CONTROL_COMBOBOX_H 5370b324cSopenharmony_ci 6370b324cSopenharmony_ci#include "../../Common/MyWindows.h" 7370b324cSopenharmony_ci 8370b324cSopenharmony_ci#include <CommCtrl.h> 9370b324cSopenharmony_ci 10370b324cSopenharmony_ci#include "../Window.h" 11370b324cSopenharmony_ci 12370b324cSopenharmony_cinamespace NWindows { 13370b324cSopenharmony_cinamespace NControl { 14370b324cSopenharmony_ci 15370b324cSopenharmony_ciclass CComboBox: public CWindow 16370b324cSopenharmony_ci{ 17370b324cSopenharmony_cipublic: 18370b324cSopenharmony_ci void ResetContent() { SendMsg(CB_RESETCONTENT, 0, 0); } 19370b324cSopenharmony_ci LRESULT AddString(LPCTSTR s) { return SendMsg(CB_ADDSTRING, 0, (LPARAM)s); } 20370b324cSopenharmony_ci #ifndef _UNICODE 21370b324cSopenharmony_ci LRESULT AddString(LPCWSTR s); 22370b324cSopenharmony_ci #endif 23370b324cSopenharmony_ci 24370b324cSopenharmony_ci /* If this parameter is -1, any current selection in the list is removed and the edit control is cleared.*/ 25370b324cSopenharmony_ci LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, MY_int_TO_WPARAM(index), 0); } 26370b324cSopenharmony_ci LRESULT SetCurSel(unsigned index) { return SendMsg(CB_SETCURSEL, index, 0); } 27370b324cSopenharmony_ci 28370b324cSopenharmony_ci /* If no item is selected, it returns CB_ERR (-1) */ 29370b324cSopenharmony_ci int GetCurSel() { return (int)SendMsg(CB_GETCURSEL, 0, 0); } 30370b324cSopenharmony_ci 31370b324cSopenharmony_ci /* If an error occurs, it is CB_ERR (-1) */ 32370b324cSopenharmony_ci int GetCount() { return (int)SendMsg(CB_GETCOUNT, 0, 0); } 33370b324cSopenharmony_ci 34370b324cSopenharmony_ci LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, MY_int_TO_WPARAM(index), 0); } 35370b324cSopenharmony_ci LRESULT GetLBText(int index, LPTSTR s) { return SendMsg(CB_GETLBTEXT, MY_int_TO_WPARAM(index), (LPARAM)s); } 36370b324cSopenharmony_ci LRESULT GetLBText(int index, CSysString &s); 37370b324cSopenharmony_ci #ifndef _UNICODE 38370b324cSopenharmony_ci LRESULT GetLBText(int index, UString &s); 39370b324cSopenharmony_ci #endif 40370b324cSopenharmony_ci 41370b324cSopenharmony_ci LRESULT SetItemData(int index, LPARAM lParam) { return SendMsg(CB_SETITEMDATA, MY_int_TO_WPARAM(index), lParam); } 42370b324cSopenharmony_ci LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, MY_int_TO_WPARAM(index), 0); } 43370b324cSopenharmony_ci LRESULT GetItemData(unsigned index) { return SendMsg(CB_GETITEMDATA, index, 0); } 44370b324cSopenharmony_ci 45370b324cSopenharmony_ci LRESULT GetItemData_of_CurSel() { return GetItemData(GetCurSel()); } 46370b324cSopenharmony_ci 47370b324cSopenharmony_ci void ShowDropDown(bool show = true) { SendMsg(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); } 48370b324cSopenharmony_ci}; 49370b324cSopenharmony_ci 50370b324cSopenharmony_ci#ifndef UNDER_CE 51370b324cSopenharmony_ci 52370b324cSopenharmony_ciclass CComboBoxEx: public CComboBox 53370b324cSopenharmony_ci{ 54370b324cSopenharmony_cipublic: 55370b324cSopenharmony_ci bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMsg(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); } 56370b324cSopenharmony_ci 57370b324cSopenharmony_ci /* Returns: 58370b324cSopenharmony_ci an INT value that represents the number of items remaining in the control. 59370b324cSopenharmony_ci If (index) is invalid, the message returns CB_ERR. */ 60370b324cSopenharmony_ci LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, MY_int_TO_WPARAM(index), 0); } 61370b324cSopenharmony_ci 62370b324cSopenharmony_ci LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_INSERTITEM, 0, (LPARAM)item); } 63370b324cSopenharmony_ci #ifndef _UNICODE 64370b324cSopenharmony_ci LRESULT InsertItem(COMBOBOXEXITEMW *item) { return SendMsg(CBEM_INSERTITEMW, 0, (LPARAM)item); } 65370b324cSopenharmony_ci #endif 66370b324cSopenharmony_ci 67370b324cSopenharmony_ci LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_SETITEM, 0, (LPARAM)item); } 68370b324cSopenharmony_ci DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, (LPARAM)exStyle); } 69370b324cSopenharmony_ci HWND GetEditControl() { return (HWND)SendMsg(CBEM_GETEDITCONTROL, 0, 0); } 70370b324cSopenharmony_ci HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMsg(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); } 71370b324cSopenharmony_ci}; 72370b324cSopenharmony_ci 73370b324cSopenharmony_ci#endif 74370b324cSopenharmony_ci 75370b324cSopenharmony_ci}} 76370b324cSopenharmony_ci 77370b324cSopenharmony_ci#endif 78