diff options
Diffstat (limited to 'CPP/Windows/Control/ComboBox.h')
-rw-r--r-- | CPP/Windows/Control/ComboBox.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/CPP/Windows/Control/ComboBox.h b/CPP/Windows/Control/ComboBox.h new file mode 100644 index 0000000..f08b1f7 --- /dev/null +++ b/CPP/Windows/Control/ComboBox.h | |||
@@ -0,0 +1,77 @@ | |||
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 | #define MY__int_TO_WPARAM(i) ((WPARAM)(INT_PTR)(i)) | ||
16 | |||
17 | class CComboBox: public CWindow | ||
18 | { | ||
19 | public: | ||
20 | void ResetContent() { SendMsg(CB_RESETCONTENT, 0, 0); } | ||
21 | LRESULT AddString(LPCTSTR s) { return SendMsg(CB_ADDSTRING, 0, (LPARAM)s); } | ||
22 | #ifndef _UNICODE | ||
23 | LRESULT AddString(LPCWSTR s); | ||
24 | #endif | ||
25 | |||
26 | /* If this parameter is -1, any current selection in the list is removed and the edit control is cleared.*/ | ||
27 | LRESULT SetCurSel(int index) { return SendMsg(CB_SETCURSEL, MY__int_TO_WPARAM(index), 0); } | ||
28 | |||
29 | /* If no item is selected, it returns CB_ERR (-1) */ | ||
30 | int GetCurSel() { return (int)SendMsg(CB_GETCURSEL, 0, 0); } | ||
31 | |||
32 | /* If an error occurs, it is CB_ERR (-1) */ | ||
33 | int GetCount() { return (int)SendMsg(CB_GETCOUNT, 0, 0); } | ||
34 | |||
35 | LRESULT GetLBTextLen(int index) { return SendMsg(CB_GETLBTEXTLEN, MY__int_TO_WPARAM(index), 0); } | ||
36 | LRESULT GetLBText(int index, LPTSTR s) { return SendMsg(CB_GETLBTEXT, MY__int_TO_WPARAM(index), (LPARAM)s); } | ||
37 | LRESULT GetLBText(int index, CSysString &s); | ||
38 | #ifndef _UNICODE | ||
39 | LRESULT GetLBText(int index, UString &s); | ||
40 | #endif | ||
41 | |||
42 | LRESULT SetItemData(int index, LPARAM lParam) { return SendMsg(CB_SETITEMDATA, MY__int_TO_WPARAM(index), lParam); } | ||
43 | LRESULT GetItemData(int index) { return SendMsg(CB_GETITEMDATA, MY__int_TO_WPARAM(index), 0); } | ||
44 | |||
45 | LRESULT GetItemData_of_CurSel() { return GetItemData(GetCurSel()); } | ||
46 | |||
47 | void ShowDropDown(bool show = true) { SendMsg(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); } | ||
48 | }; | ||
49 | |||
50 | #ifndef UNDER_CE | ||
51 | |||
52 | class CComboBoxEx: public CComboBox | ||
53 | { | ||
54 | public: | ||
55 | bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMsg(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); } | ||
56 | |||
57 | /* Returns: | ||
58 | an INT value that represents the number of items remaining in the control. | ||
59 | If (index) is invalid, the message returns CB_ERR. */ | ||
60 | LRESULT DeleteItem(int index) { return SendMsg(CBEM_DELETEITEM, MY__int_TO_WPARAM(index), 0); } | ||
61 | |||
62 | LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_INSERTITEM, 0, (LPARAM)item); } | ||
63 | #ifndef _UNICODE | ||
64 | LRESULT InsertItem(COMBOBOXEXITEMW *item) { return SendMsg(CBEM_INSERTITEMW, 0, (LPARAM)item); } | ||
65 | #endif | ||
66 | |||
67 | LRESULT SetItem(COMBOBOXEXITEM *item) { return SendMsg(CBEM_SETITEM, 0, (LPARAM)item); } | ||
68 | DWORD SetExtendedStyle(DWORD exMask, DWORD exStyle) { return (DWORD)SendMsg(CBEM_SETEXTENDEDSTYLE, exMask, exStyle); } | ||
69 | HWND GetEditControl() { return (HWND)SendMsg(CBEM_GETEDITCONTROL, 0, 0); } | ||
70 | HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMsg(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); } | ||
71 | }; | ||
72 | |||
73 | #endif | ||
74 | |||
75 | }} | ||
76 | |||
77 | #endif | ||