diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/nu/ComboBox.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/nu/ComboBox.h')
-rw-r--r-- | Src/nu/ComboBox.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/Src/nu/ComboBox.h b/Src/nu/ComboBox.h new file mode 100644 index 00000000..150d6a6b --- /dev/null +++ b/Src/nu/ComboBox.h @@ -0,0 +1,105 @@ +#ifndef NULLSOFT_UTILITY_COMBOBOX_H +#define NULLSOFT_UTILITY_COMBOBOX_H +#include <windows.h> +class ComboBox +{ +public: + ComboBox(HWND hwndDlg, int id) + { + cbHwnd = GetDlgItem(hwndDlg, id); + } + + ComboBox(HWND control) + { + cbHwnd = control; + } + + operator HWND() + { + return cbHwnd; + } + + LRESULT AddString(const wchar_t *string) + { + return SendMessageW(cbHwnd, CB_ADDSTRING, 0, (LPARAM)string); + } + + LRESULT AddString(const wchar_t *string, LPARAM data) + { + LRESULT index = SendMessageW(cbHwnd, CB_ADDSTRING, 0, (LPARAM)string); + SendMessage(cbHwnd, CB_SETITEMDATA, index, data); + return index; + } + + LRESULT AddString(const char *string) + { + return SendMessageA(cbHwnd, CB_ADDSTRING, 0, (LPARAM)string); + } + + void SetItemData(LPARAM index, LPARAM data) + { + SendMessage(cbHwnd, CB_SETITEMDATA, index, data); + } + + int GetCount() + { + return (int)SendMessage(cbHwnd, CB_GETCOUNT, 0, 0); + } + + LRESULT GetItemData(LPARAM index) + { + return SendMessage(cbHwnd, CB_GETITEMDATA, index, 0); + } + + void Clear() + { + SendMessage(cbHwnd, CB_RESETCONTENT, 0, 0); + } + + void SelectItem(LPARAM index) + { + SendMessage(cbHwnd, CB_SETCURSEL, index, 0); + } + + LPARAM GetSelection() + { + return SendMessage(cbHwnd, CB_GETCURSEL, 0, 0); + } + + LRESULT SelectString(const wchar_t *str) + { + return SendMessageW(cbHwnd, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)str); + } + + LRESULT GetTextLen(int index) + { + return SendMessageW(cbHwnd, CB_GETLBTEXTLEN, (WPARAM)index, 0); + } + + void GetText(int index, wchar_t *str) + { + SendMessageW(cbHwnd, CB_GETLBTEXT, (WPARAM)index, (LPARAM)str); + } +#if (_WIN32_WINNT >= 0x0501) + void SetCueBanner(const wchar_t *str) + { + SendMessageW(cbHwnd, CB_SETCUEBANNER, 0, (LPARAM)str); + //CB_SETCUEBANNER; + } +#endif + + void SetEditText(const wchar_t *str) + { + SendMessageW(cbHwnd, WM_SETTEXT, 0, (LPARAM)str); + } + + unsigned int GetEditText(wchar_t *str, unsigned int cch) + { + return (unsigned int)SendMessageW(cbHwnd, WM_GETTEXT, (WPARAM)cch, (LPARAM)str); + } + + + HWND cbHwnd; +}; + +#endif
\ No newline at end of file |