Commented out unused variables to prevent needless compiler warnings.
[wine] / dlls / comctl32 / comboex.c
1 /*
2  * ComboBoxEx control
3  *
4  * Copyright 1998 Eric Kohl
5  *
6  * NOTES
7  *   This is just a dummy control. An author is needed! Any volunteers?
8  *   I will only improve this control once in a while.
9  *     Eric <ekohl@abo.rhein-zeitung.de>
10  *
11  * TODO:
12  *   - All messages.
13  *   - All notifications.
14  *
15  * FIXME:
16  *   - should include "combo.h" 
17  */
18
19 #include "windows.h"
20 #include "commctrl.h"
21 #include "comboex.h"
22 #include "win.h"
23 #include "debug.h"
24
25 #define ID_CB_EDIT    1001
26
27 #define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)wndPtr->wExtra[0])
28
29
30 /* << COMBOEX_DeleteItem >> */
31
32
33 __inline__ static LRESULT
34 COMBOEX_GetComboControl (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
35 {
36     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
37
38     TRACE (comboex, "\n");
39
40     return (LRESULT)infoPtr->hwndCombo;
41 }
42
43
44 __inline__ static LRESULT
45 COMBOEX_GetEditControl (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
46 {
47     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
48
49     if ((wndPtr->dwStyle & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
50         return 0;
51
52     TRACE (comboex, "-- 0x%x\n", GetDlgItem32 (infoPtr->hwndCombo, ID_CB_EDIT));
53
54     return (LRESULT)GetDlgItem32 (infoPtr->hwndCombo, ID_CB_EDIT);
55 }
56
57
58 __inline__ static LRESULT
59 COMBOEX_GetExtendedStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
60 {
61     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
62
63     return (LRESULT)infoPtr->dwExtStyle;
64 }
65
66
67 __inline__ static LRESULT
68 COMBOEX_GetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
69 {
70     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
71
72     TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
73
74     return (LRESULT)infoPtr->himl;
75 }
76
77
78
79
80 static LRESULT
81 COMBOEX_InsertItem32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
82 {
83     /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr); */
84
85     FIXME (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
86
87     return -1;
88 }
89
90
91
92 static LRESULT
93 COMBOEX_SetExtendedStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
94 {
95     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
96     DWORD dwTemp;
97
98     TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
99
100     dwTemp = infoPtr->dwExtStyle;
101
102     if ((DWORD)wParam) {
103         infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
104     }
105     else
106         infoPtr->dwExtStyle = (DWORD)lParam;
107
108     /* FIXME: repaint?? */
109
110     return (LRESULT)dwTemp;
111 }
112
113
114 __inline__ static LRESULT
115 COMBOEX_SetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
116 {
117     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
118     HIMAGELIST himlTemp;
119
120     TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
121
122     himlTemp = infoPtr->himl;
123     infoPtr->himl = (HIMAGELIST)lParam;
124
125     return (LRESULT)himlTemp;
126 }
127
128
129 static LRESULT
130 COMBOEX_SetItem32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
131 {
132     /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr); */
133
134     FIXME (comboex, "(%p): stub\n", (LPVOID)lParam);
135
136     return TRUE;
137 }
138
139
140 /* << COMBOEX_SetItem32W >> */
141
142
143 __inline__ static LRESULT
144 COMBOEX_Forward (WND *wndPtr, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
145 {
146     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
147
148     FIXME (comboex, "(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
149
150     if (infoPtr->hwndCombo)    
151         return SendMessage32A (infoPtr->hwndCombo, uMsg, wParam, lParam);
152
153     return 0;
154 }
155
156
157 static LRESULT
158 COMBOEX_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
159 {
160     COMBOEX_INFO *infoPtr;
161     DWORD dwComboStyle;
162
163     /* allocate memory for info structure */
164     infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
165     wndPtr->wExtra[0] = (DWORD)infoPtr;
166
167     if (infoPtr == NULL) {
168         ERR (listview, "could not allocate info memory!\n");
169         return 0;
170     }
171
172     if ((COMBOEX_INFO*)wndPtr->wExtra[0] != infoPtr) {
173         ERR (listview, "pointer assignment error!\n");
174         return 0;
175     }
176
177
178     /* initialize info structure */
179
180
181     /* create combo box */
182     dwComboStyle = 
183         wndPtr->dwStyle & (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
184
185     infoPtr->hwndCombo =
186         CreateWindow32A ("ComboBox", "",
187                          WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
188                          0, 0, 0, 0, wndPtr->hwndSelf, (HMENU32)1,
189                          wndPtr->hInstance, NULL);
190
191
192     return 0;
193 }
194
195
196 static LRESULT
197 COMBOEX_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
198 {
199     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
200
201
202     if (infoPtr->hwndCombo)
203         DestroyWindow32 (infoPtr->hwndCombo);
204
205
206
207
208     /* free comboex info data */
209     COMCTL32_Free (infoPtr);
210
211     return 0;
212 }
213
214
215 static LRESULT
216 COMBOEX_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
217 {
218     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
219     RECT32 rect;
220
221     GetClientRect32 (wndPtr->hwndSelf, &rect);
222
223     MoveWindow32 (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
224                   rect.bottom - rect.top, TRUE);
225
226     return 0;
227 }
228
229
230 LRESULT WINAPI
231 COMBOEX_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
232 {
233     WND *wndPtr = WIN_FindWndPtr(hwnd);
234
235     switch (uMsg)
236     {
237 /*      case CBEM_DELETEITEM: */
238
239         case CBEM_GETCOMBOCONTROL:
240             return COMBOEX_GetComboControl (wndPtr, wParam, lParam);
241
242         case CBEM_GETEDITCONTROL:
243             return COMBOEX_GetEditControl (wndPtr, wParam, lParam);
244
245         case CBEM_GETEXTENDEDSTYLE:
246             return COMBOEX_GetExtendedStyle (wndPtr, wParam, lParam);
247
248         case CBEM_GETIMAGELIST:
249             return COMBOEX_GetImageList (wndPtr, wParam, lParam);
250
251 /*      case CBEM_GETITEM32A:
252         case CBEM_GETITEM32W:
253         case CBEM_GETUNICODEFORMAT:
254         case CBEM_HASEDITCHANGED:
255 */
256
257         case CBEM_INSERTITEM32A:
258             return COMBOEX_InsertItem32A (wndPtr, wParam, lParam);
259
260 /*      case CBEM_INSERTITEM32W: */
261
262         case CBEM_SETEXTENDEDSTYLE:
263             return COMBOEX_SetExtendedStyle (wndPtr, wParam, lParam);
264
265         case CBEM_SETIMAGELIST:
266             return COMBOEX_SetImageList (wndPtr, wParam, lParam);
267
268         case CBEM_SETITEM32A:
269             return COMBOEX_SetItem32A (wndPtr, wParam, lParam);
270
271 /*      case CBEM_SETITEM32W:
272         case CBEM_SETUNICODEFORMAT:
273 */
274
275         case CB_DELETESTRING32:
276         case CB_FINDSTRINGEXACT32:
277         case CB_GETCOUNT32:
278         case CB_GETCURSEL32:
279         case CB_GETDROPPEDCONTROLRECT32:
280         case CB_GETDROPPEDSTATE32:
281         case CB_GETITEMDATA32:
282         case CB_GETITEMHEIGHT32:
283         case CB_GETLBTEXT32:
284         case CB_GETLBTEXTLEN32:
285         case CB_GETEXTENDEDUI32:
286         case CB_LIMITTEXT32:
287         case CB_RESETCONTENT32:
288         case CB_SELECTSTRING32:
289         case CB_SETCURSEL32:
290         case CB_SETDROPPEDWIDTH32:
291         case CB_SETEXTENDEDUI32:
292         case CB_SETITEMDATA32:
293         case CB_SETITEMHEIGHT32:
294         case CB_SHOWDROPDOWN32:
295             return COMBOEX_Forward (wndPtr, uMsg, wParam, lParam);
296
297
298         case WM_CREATE:
299             return COMBOEX_Create (wndPtr, wParam, lParam);
300
301         case WM_DESTROY:
302             return COMBOEX_Destroy (wndPtr, wParam, lParam);
303
304         case WM_SIZE:
305             return COMBOEX_Size (wndPtr, wParam, lParam);
306
307         default:
308             if (uMsg >= WM_USER)
309                 ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n",
310                      uMsg, wParam, lParam);
311             return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
312     }
313     return 0;
314 }
315
316
317 VOID
318 COMBOEX_Register (VOID)
319 {
320     WNDCLASS32A wndClass;
321
322     if (GlobalFindAtom32A (WC_COMBOBOXEX32A)) return;
323
324     ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
325     wndClass.style         = CS_GLOBALCLASS;
326     wndClass.lpfnWndProc   = (WNDPROC32)COMBOEX_WindowProc;
327     wndClass.cbClsExtra    = 0;
328     wndClass.cbWndExtra    = sizeof(COMBOEX_INFO *);
329     wndClass.hCursor       = LoadCursor32A (0, IDC_ARROW32A);
330     wndClass.hbrBackground = (HBRUSH32)(COLOR_WINDOW + 1);
331     wndClass.lpszClassName = WC_COMBOBOXEX32A;
332  
333     RegisterClass32A (&wndClass);
334 }
335
336
337 VOID
338 COMBOEX_Unregister (VOID)
339 {
340     if (GlobalFindAtom32A (WC_COMBOBOXEX32A))
341         UnregisterClass32A (WC_COMBOBOXEX32A, (HINSTANCE32)NULL);
342 }
343