-
Notifications
You must be signed in to change notification settings - Fork 8
/
UICombox.cpp
275 lines (228 loc) · 7.21 KB
/
UICombox.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#include "UICombox.h"
UICombox::UICombox()
{
}
UICombox::~UICombox()
{
DestroyWindow(m_hWnd);
}
/////////////////////////////////////////////////////////////////////////////
// CComboBox
BOOL UICombox::Create(DWORD dwStyle, const RECT& rect, HWND pParentWnd,
UINT nID)
{
return CWndUI::Create(_T("COMBOBOX"), NULL, dwStyle, rect, pParentWnd, nID);
}
// Derived class is responsible for implementing these handlers
// for owner/self draw controls (except for the optional DeleteItem)
void UICombox::DrawItem(LPDRAWITEMSTRUCT)
{
ASSERT(FALSE);
}
void UICombox::MeasureItem(LPMEASUREITEMSTRUCT)
{
ASSERT(FALSE);
}
int UICombox::CompareItem(LPCOMPAREITEMSTRUCT)
{
ASSERT(FALSE); return 0;
}
void UICombox::DeleteItem(LPDELETEITEMSTRUCT)
{ /* default to nothing */
}
BOOL UICombox::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam,
LRESULT* pResult)
{
switch (message)
{
case WM_DRAWITEM:
ASSERT(pResult == NULL); // no return value expected
DrawItem((LPDRAWITEMSTRUCT)lParam);
break;
case WM_MEASUREITEM:
ASSERT(pResult == NULL); // no return value expected
MeasureItem((LPMEASUREITEMSTRUCT)lParam);
break;
case WM_COMPAREITEM:
ASSERT(pResult != NULL); // return value expected
*pResult = CompareItem((LPCOMPAREITEMSTRUCT)lParam);
break;
case WM_DELETEITEM:
ASSERT(pResult == NULL); // no return value expected
DeleteItem((LPDELETEITEMSTRUCT)lParam);
break;
default:
//return CWnd::OnChildNotify(message, wParam, lParam, pResult);
break;
}
return TRUE;
}
int UICombox::GetCount() const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_GETCOUNT, 0, 0);
}
int UICombox::GetCurSel() const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_GETCURSEL, 0, 0);
}
int UICombox::SetCurSel(int nSelect)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SETCURSEL, nSelect, 0);
}
DWORD UICombox::GetEditSel() const
{
ASSERT(::IsWindow(m_hWnd)); return DWORD(::SendMessage(m_hWnd, CB_GETEDITSEL, 0, 0));
}
BOOL UICombox::LimitText(int nMaxChars)
{
ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, CB_LIMITTEXT, nMaxChars, 0);
}
BOOL UICombox::SetEditSel(_In_ int nStartChar, _In_ int nEndChar)
{
ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar));
}
DWORD_PTR UICombox::GetItemData(int nIndex) const
{
ASSERT(::IsWindow(m_hWnd)); return ::SendMessage(m_hWnd, CB_GETITEMDATA, nIndex, 0);
}
int UICombox::SetItemData(int nIndex, DWORD_PTR dwItemData)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SETITEMDATA, nIndex, (LPARAM)dwItemData);
}
void* UICombox::GetItemDataPtr(int nIndex) const
{
ASSERT(::IsWindow(m_hWnd)); return (LPVOID)GetItemData(nIndex);
}
int UICombox::SetItemDataPtr(int nIndex, void* pData)
{
ASSERT(::IsWindow(m_hWnd)); return SetItemData(nIndex, (DWORD_PTR)(LPVOID)pData);
}
DuiLib::CDuiString UICombox::GetText() const
{
TCHAR buff[256] = {0};
::GetWindowText(m_hWnd, buff, 256);
return buff;
}
int UICombox::GetLBText(_In_ int nIndex, _Pre_notnull_ _Post_z_ LPTSTR lpszText) const
{
ASSERT(::IsWindow(m_hWnd));
return (int)::SendMessage(m_hWnd, CB_GETLBTEXT, nIndex, (LPARAM)lpszText);
}
int UICombox::GetLBTextLen(int nIndex) const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_GETLBTEXTLEN, nIndex, 0);
}
void UICombox::ShowDropDown(BOOL bShowIt)
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, CB_SHOWDROPDOWN, bShowIt, 0);
}
int UICombox::AddString(LPCTSTR lpszString)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_ADDSTRING, 0, (LPARAM)lpszString);
}
int UICombox::DeleteString(UINT nIndex)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_DELETESTRING, nIndex, 0);
}
int UICombox::InsertString(_In_ int nIndex, _In_z_ LPCTSTR lpszString)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_INSERTSTRING, nIndex, (LPARAM)lpszString);
}
void UICombox::ResetContent()
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0);
}
int UICombox::Dir(_In_ UINT attr, _In_ LPCTSTR lpszWildCard)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_DIR, attr, (LPARAM)lpszWildCard);
}
int UICombox::FindString(_In_ int nStartAfter, _In_z_ LPCTSTR lpszString) const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_FINDSTRING, nStartAfter,
(LPARAM)lpszString);
}
int UICombox::SelectString(int nStartAfter, LPCTSTR lpszString)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SELECTSTRING,
nStartAfter, (LPARAM)lpszString);
}
void UICombox::Clear()
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, WM_CLEAR, 0, 0);
}
void UICombox::Copy()
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, WM_COPY, 0, 0);
}
void UICombox::Cut()
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, WM_CUT, 0, 0);
}
void UICombox::Paste()
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, WM_PASTE, 0, 0);
}
int UICombox::SetItemHeight(int nIndex, UINT cyItemHeight)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0));
}
int UICombox::GetItemHeight(int nIndex) const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_GETITEMHEIGHT, nIndex, 0L);
}
int UICombox::FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind);
}
int UICombox::SetExtendedUI(BOOL bExtended)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SETEXTENDEDUI, bExtended, 0L);
}
BOOL UICombox::GetExtendedUI() const
{
ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, CB_GETEXTENDEDUI, 0, 0L);
}
void UICombox::GetDroppedControlRect(LPRECT lprect) const
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)lprect);
}
BOOL UICombox::GetDroppedState() const
{
ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, CB_GETDROPPEDSTATE, 0, 0L);
}
LCID UICombox::GetLocale() const
{
ASSERT(::IsWindow(m_hWnd)); return (LCID)::SendMessage(m_hWnd, CB_GETLOCALE, 0, 0);
}
LCID UICombox::SetLocale(LCID nNewLocale)
{
ASSERT(::IsWindow(m_hWnd)); return (LCID)::SendMessage(m_hWnd, CB_SETLOCALE, (WPARAM)nNewLocale, 0);
}
int UICombox::GetTopIndex() const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_GETTOPINDEX, 0, 0);
}
int UICombox::SetTopIndex(int nIndex)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SETTOPINDEX, nIndex, 0);
}
int UICombox::InitStorage(int nItems, UINT nBytes)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_INITSTORAGE, (WPARAM)nItems, nBytes);
}
void UICombox::SetHorizontalExtent(UINT nExtent)
{
ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, CB_SETHORIZONTALEXTENT, nExtent, 0);
}
UINT UICombox::GetHorizontalExtent() const
{
ASSERT(::IsWindow(m_hWnd)); return (UINT)::SendMessage(m_hWnd, CB_GETHORIZONTALEXTENT, 0, 0);
}
int UICombox::SetDroppedWidth(UINT nWidth)
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_SETDROPPEDWIDTH, nWidth, 0);
}
int UICombox::GetDroppedWidth() const
{
ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, CB_GETDROPPEDWIDTH, 0, 0);
}