source: trunk/src/comctl32/comboex.cpp@ 3182

Last change on this file since 3182 was 3182, checked in by cbratschi, 25 years ago

bug fixes and improvements

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