source: trunk/src/comctl32/comboex.c@ 60

Last change on this file since 60 was 60, checked in by achimha, 26 years ago

* empty log message *

File size: 7.1 KB
Line 
1/*
2 * ComboBoxEx control
3 *
4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 1999 Achim Hasenmueller
6 *
7 * NOTES
8 * This is just a dummy control. An author is needed! Any volunteers?
9 * I will only improve this control once in a while.
10 * Eric <ekohl@abo.rhein-zeitung.de>
11 *
12 * TODO:
13 * - All messages.
14 * - All notifications.
15 *
16 * FIXME:
17 * - should include "combo.h"
18 */
19
20#include "winbase.h"
21#include "commctrl.h"
22#include "comctl32.h"
23#include "comboex.h"
24
25
26#define ID_CB_EDIT 1001
27
28#define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
29
30
31/* << COMBOEX_DeleteItem >> */
32
33
34static LRESULT
35COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
36{
37 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
38
39// TRACE (comboex, "\n");
40
41 return (LRESULT)infoPtr->hwndCombo;
42}
43
44
45static LRESULT
46COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
47{
48 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
49
50 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
51 return 0;
52
53// TRACE (comboex, "-- 0x%x\n", GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT));
54
55 return (LRESULT)GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT);
56}
57
58
59static LRESULT
60COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
61{
62 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
63
64 return (LRESULT)infoPtr->dwExtStyle;
65}
66
67
68static LRESULT
69COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
70{
71 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
72
73// TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
74
75 return (LRESULT)infoPtr->himl;
76}
77
78
79
80
81static LRESULT
82COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
83{
84 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); */
85
86// FIXME (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
87
88 return -1;
89}
90
91
92
93static LRESULT
94COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
95{
96 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
97 DWORD dwTemp;
98
99// TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
100
101 dwTemp = infoPtr->dwExtStyle;
102
103 if ((DWORD)wParam) {
104 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
105 }
106 else
107 infoPtr->dwExtStyle = (DWORD)lParam;
108
109 /* FIXME: repaint?? */
110
111 return (LRESULT)dwTemp;
112}
113
114
115static LRESULT
116COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
117{
118 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
119 HIMAGELIST himlTemp;
120
121// TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
122
123 himlTemp = infoPtr->himl;
124 infoPtr->himl = (HIMAGELIST)lParam;
125
126 return (LRESULT)himlTemp;
127}
128
129
130static LRESULT
131COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
132{
133 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); */
134
135// FIXME (comboex, "(%p): stub\n", (LPVOID)lParam);
136
137 return TRUE;
138}
139
140
141/* << COMBOEX_SetItem32W >> */
142
143
144static LRESULT
145COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
146{
147 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
148
149// FIXME (comboex, "(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
150
151 if (infoPtr->hwndCombo)
152 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
153
154 return 0;
155}
156
157
158static LRESULT
159COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
160{
161 COMBOEX_INFO *infoPtr;
162 DWORD dwComboStyle;
163
164 /* allocate memory for info structure */
165 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
166 if (infoPtr == NULL) {
167// ERR (comboex, "could not allocate info memory!\n");
168 return 0;
169 }
170
171 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
172
173
174 /* initialize info structure */
175
176
177 /* create combo box */
178 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
179 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
180
181 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
182 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
183 0, 0, 0, 0, hwnd, (HMENU)1,
184 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
185
186 return 0;
187}
188
189
190static LRESULT
191COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
192{
193 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
194
195
196 if (infoPtr->hwndCombo)
197 DestroyWindow (infoPtr->hwndCombo);
198
199
200
201
202 /* free comboex info data */
203 COMCTL32_Free (infoPtr);
204
205 return 0;
206}
207
208
209static LRESULT
210COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
211{
212 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
213 RECT rect;
214
215 GetClientRect (hwnd, &rect);
216
217 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
218 rect.bottom - rect.top, TRUE);
219
220 return 0;
221}
222
223
224LRESULT WINAPI
225COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
226{
227 switch (uMsg)
228 {
229/* case CBEM_DELETEITEM: */
230
231 case CBEM_GETCOMBOCONTROL:
232 return COMBOEX_GetComboControl (hwnd, wParam, lParam);
233
234 case CBEM_GETEDITCONTROL:
235 return COMBOEX_GetEditControl (hwnd, wParam, lParam);
236
237 case CBEM_GETEXTENDEDSTYLE:
238 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
239
240 case CBEM_GETIMAGELIST:
241 return COMBOEX_GetImageList (hwnd, wParam, lParam);
242
243/* case CBEM_GETITEM32A:
244 case CBEM_GETITEM32W:
245 case CBEM_GETUNICODEFORMAT:
246 case CBEM_HASEDITCHANGED:
247*/
248
249 case CBEM_INSERTITEMA:
250 return COMBOEX_InsertItemA (hwnd, wParam, lParam);
251
252/* case CBEM_INSERTITEM32W: */
253
254 case CBEM_SETEXTENDEDSTYLE:
255 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
256
257 case CBEM_SETIMAGELIST:
258 return COMBOEX_SetImageList (hwnd, wParam, lParam);
259
260 case CBEM_SETITEMA:
261 return COMBOEX_SetItemA (hwnd, wParam, lParam);
262
263/* case CBEM_SETITEM32W:
264 case CBEM_SETUNICODEFORMAT:
265*/
266
267 case CB_DELETESTRING:
268 case CB_FINDSTRINGEXACT:
269 case CB_GETCOUNT:
270 case CB_GETCURSEL:
271 case CB_GETDROPPEDCONTROLRECT:
272 case CB_GETDROPPEDSTATE:
273 case CB_GETITEMDATA:
274 case CB_GETITEMHEIGHT:
275 case CB_GETLBTEXT:
276 case CB_GETLBTEXTLEN:
277 case CB_GETEXTENDEDUI:
278 case CB_LIMITTEXT:
279 case CB_RESETCONTENT:
280 case CB_SELECTSTRING:
281 case CB_SETCURSEL:
282 case CB_SETDROPPEDWIDTH:
283 case CB_SETEXTENDEDUI:
284 case CB_SETITEMDATA:
285 case CB_SETITEMHEIGHT:
286 case CB_SHOWDROPDOWN:
287 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
288
289
290 case WM_CREATE:
291 return COMBOEX_Create (hwnd, wParam, lParam);
292
293 case WM_DESTROY:
294 return COMBOEX_Destroy (hwnd, wParam, lParam);
295
296 case WM_SIZE:
297 return COMBOEX_Size (hwnd, wParam, lParam);
298
299 default:
300// if (uMsg >= WM_USER)
301// ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n",
302// uMsg, wParam, lParam);
303 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
304 }
305 return 0;
306}
307
308
309VOID
310COMBOEX_Register (VOID)
311{
312 WNDCLASSA wndClass;
313
314 if (GlobalFindAtomA (WC_COMBOBOXEXA)) return;
315
316 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
317 wndClass.style = CS_GLOBALCLASS;
318 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
319 wndClass.cbClsExtra = 0;
320 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
321 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
322 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
323 wndClass.lpszClassName = WC_COMBOBOXEXA;
324
325 RegisterClassA (&wndClass);
326}
327
328
329VOID
330COMBOEX_Unregister (VOID)
331{
332 if (GlobalFindAtomA (WC_COMBOBOXEXA))
333 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);
334}
335
Note: See TracBrowser for help on using the repository browser.