Optimized include/*.h: (recursively) include all headers needed by
[wine/testsucceed.git] / dlls / comctl32 / comboex.c
bloba77f67914c92d00b3ba83fb19a7b5f0aca44a160
1 /*
2 * ComboBoxEx control
4 * Copyright 1998 Eric Kohl
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>
11 * TODO:
12 * - All messages.
13 * - All notifications.
15 * FIXME:
16 * - should include "combo.h"
19 #include "commctrl.h"
20 #include "comboex.h"
21 #include "win.h"
22 #include "debug.h"
24 #define ID_CB_EDIT 1001
26 #define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)wndPtr->wExtra[0])
29 /* << COMBOEX_DeleteItem >> */
32 __inline__ static LRESULT
33 COMBOEX_GetComboControl (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
35 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
37 TRACE (comboex, "\n");
39 return (LRESULT)infoPtr->hwndCombo;
43 __inline__ static LRESULT
44 COMBOEX_GetEditControl (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
46 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
48 if ((wndPtr->dwStyle & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
49 return 0;
51 TRACE (comboex, "-- 0x%x\n", GetDlgItem32 (infoPtr->hwndCombo, ID_CB_EDIT));
53 return (LRESULT)GetDlgItem32 (infoPtr->hwndCombo, ID_CB_EDIT);
57 __inline__ static LRESULT
58 COMBOEX_GetExtendedStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
60 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
62 return (LRESULT)infoPtr->dwExtStyle;
66 __inline__ static LRESULT
67 COMBOEX_GetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
69 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
71 TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
73 return (LRESULT)infoPtr->himl;
79 static LRESULT
80 COMBOEX_InsertItem32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
82 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr); */
84 FIXME (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
86 return -1;
91 static LRESULT
92 COMBOEX_SetExtendedStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
94 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
95 DWORD dwTemp;
97 TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
99 dwTemp = infoPtr->dwExtStyle;
101 if ((DWORD)wParam) {
102 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
104 else
105 infoPtr->dwExtStyle = (DWORD)lParam;
107 /* FIXME: repaint?? */
109 return (LRESULT)dwTemp;
113 __inline__ static LRESULT
114 COMBOEX_SetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
116 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
117 HIMAGELIST himlTemp;
119 TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
121 himlTemp = infoPtr->himl;
122 infoPtr->himl = (HIMAGELIST)lParam;
124 return (LRESULT)himlTemp;
128 static LRESULT
129 COMBOEX_SetItem32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
131 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr); */
133 FIXME (comboex, "(%p): stub\n", (LPVOID)lParam);
135 return TRUE;
139 /* << COMBOEX_SetItem32W >> */
142 __inline__ static LRESULT
143 COMBOEX_Forward (WND *wndPtr, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
145 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
147 FIXME (comboex, "(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
149 if (infoPtr->hwndCombo)
150 return SendMessage32A (infoPtr->hwndCombo, uMsg, wParam, lParam);
152 return 0;
156 static LRESULT
157 COMBOEX_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
159 COMBOEX_INFO *infoPtr;
160 DWORD dwComboStyle;
162 /* allocate memory for info structure */
163 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
164 wndPtr->wExtra[0] = (DWORD)infoPtr;
166 if (infoPtr == NULL) {
167 ERR (listview, "could not allocate info memory!\n");
168 return 0;
171 if ((COMBOEX_INFO*)wndPtr->wExtra[0] != infoPtr) {
172 ERR (listview, "pointer assignment error!\n");
173 return 0;
177 /* initialize info structure */
180 /* create combo box */
181 dwComboStyle =
182 wndPtr->dwStyle & (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
184 infoPtr->hwndCombo =
185 CreateWindow32A ("ComboBox", "",
186 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
187 0, 0, 0, 0, wndPtr->hwndSelf, (HMENU32)1,
188 wndPtr->hInstance, NULL);
191 return 0;
195 static LRESULT
196 COMBOEX_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
198 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
201 if (infoPtr->hwndCombo)
202 DestroyWindow32 (infoPtr->hwndCombo);
207 /* free comboex info data */
208 COMCTL32_Free (infoPtr);
210 return 0;
214 static LRESULT
215 COMBOEX_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
217 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
218 RECT32 rect;
220 GetClientRect32 (wndPtr->hwndSelf, &rect);
222 MoveWindow32 (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
223 rect.bottom - rect.top, TRUE);
225 return 0;
229 LRESULT WINAPI
230 COMBOEX_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
232 WND *wndPtr = WIN_FindWndPtr(hwnd);
234 switch (uMsg)
236 /* case CBEM_DELETEITEM: */
238 case CBEM_GETCOMBOCONTROL:
239 return COMBOEX_GetComboControl (wndPtr, wParam, lParam);
241 case CBEM_GETEDITCONTROL:
242 return COMBOEX_GetEditControl (wndPtr, wParam, lParam);
244 case CBEM_GETEXTENDEDSTYLE:
245 return COMBOEX_GetExtendedStyle (wndPtr, wParam, lParam);
247 case CBEM_GETIMAGELIST:
248 return COMBOEX_GetImageList (wndPtr, wParam, lParam);
250 /* case CBEM_GETITEM32A:
251 case CBEM_GETITEM32W:
252 case CBEM_GETUNICODEFORMAT:
253 case CBEM_HASEDITCHANGED:
256 case CBEM_INSERTITEM32A:
257 return COMBOEX_InsertItem32A (wndPtr, wParam, lParam);
259 /* case CBEM_INSERTITEM32W: */
261 case CBEM_SETEXTENDEDSTYLE:
262 return COMBOEX_SetExtendedStyle (wndPtr, wParam, lParam);
264 case CBEM_SETIMAGELIST:
265 return COMBOEX_SetImageList (wndPtr, wParam, lParam);
267 case CBEM_SETITEM32A:
268 return COMBOEX_SetItem32A (wndPtr, wParam, lParam);
270 /* case CBEM_SETITEM32W:
271 case CBEM_SETUNICODEFORMAT:
274 case CB_DELETESTRING32:
275 case CB_FINDSTRINGEXACT32:
276 case CB_GETCOUNT32:
277 case CB_GETCURSEL32:
278 case CB_GETDROPPEDCONTROLRECT32:
279 case CB_GETDROPPEDSTATE32:
280 case CB_GETITEMDATA32:
281 case CB_GETITEMHEIGHT32:
282 case CB_GETLBTEXT32:
283 case CB_GETLBTEXTLEN32:
284 case CB_GETEXTENDEDUI32:
285 case CB_LIMITTEXT32:
286 case CB_RESETCONTENT32:
287 case CB_SELECTSTRING32:
288 case CB_SETCURSEL32:
289 case CB_SETDROPPEDWIDTH32:
290 case CB_SETEXTENDEDUI32:
291 case CB_SETITEMDATA32:
292 case CB_SETITEMHEIGHT32:
293 case CB_SHOWDROPDOWN32:
294 return COMBOEX_Forward (wndPtr, uMsg, wParam, lParam);
297 case WM_CREATE:
298 return COMBOEX_Create (wndPtr, wParam, lParam);
300 case WM_DESTROY:
301 return COMBOEX_Destroy (wndPtr, wParam, lParam);
303 case WM_SIZE:
304 return COMBOEX_Size (wndPtr, wParam, lParam);
306 default:
307 if (uMsg >= WM_USER)
308 ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n",
309 uMsg, wParam, lParam);
310 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
312 return 0;
316 VOID
317 COMBOEX_Register (VOID)
319 WNDCLASS32A wndClass;
321 if (GlobalFindAtom32A (WC_COMBOBOXEX32A)) return;
323 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
324 wndClass.style = CS_GLOBALCLASS;
325 wndClass.lpfnWndProc = (WNDPROC32)COMBOEX_WindowProc;
326 wndClass.cbClsExtra = 0;
327 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
328 wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
329 wndClass.hbrBackground = (HBRUSH32)(COLOR_WINDOW + 1);
330 wndClass.lpszClassName = WC_COMBOBOXEX32A;
332 RegisterClass32A (&wndClass);
336 VOID
337 COMBOEX_Unregister (VOID)
339 if (GlobalFindAtom32A (WC_COMBOBOXEX32A))
340 UnregisterClass32A (WC_COMBOBOXEX32A, (HINSTANCE32)NULL);