Removed all non-standard common control headers from the include
[wine/hacks.git] / dlls / comctl32 / comboex.c
blob30794d74cbc471c3ef5a9dbaf40d5996ee4b3131
1 /*
2 * ComboBoxEx control
4 * Copyright 1998, 1999 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 "winbase.h"
20 #include "commctrl.h"
21 #include "debugtools.h"
23 DEFAULT_DEBUG_CHANNEL(comboex);
25 typedef struct
27 HIMAGELIST himl;
28 HWND hwndCombo;
29 DWORD dwExtStyle;
30 } COMBOEX_INFO;
32 #define ID_CB_EDIT 1001
34 #define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
37 /* << COMBOEX_DeleteItem >> */
40 inline static LRESULT
41 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
43 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
45 TRACE("\n");
47 return (LRESULT)infoPtr->hwndCombo;
51 inline static LRESULT
52 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
54 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
56 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
57 return 0;
59 TRACE("-- 0x%x\n", GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT));
61 return (LRESULT)GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT);
65 inline static LRESULT
66 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
68 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
70 return (LRESULT)infoPtr->dwExtStyle;
74 inline static LRESULT
75 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
77 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
79 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
81 return (LRESULT)infoPtr->himl;
87 static LRESULT
88 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
90 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); */
92 FIXME("(0x%08x 0x%08lx)\n", wParam, lParam);
94 return -1;
99 static LRESULT
100 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
102 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
103 DWORD dwTemp;
105 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
107 dwTemp = infoPtr->dwExtStyle;
109 if ((DWORD)wParam) {
110 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
112 else
113 infoPtr->dwExtStyle = (DWORD)lParam;
115 /* FIXME: repaint?? */
117 return (LRESULT)dwTemp;
121 inline static LRESULT
122 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
124 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
125 HIMAGELIST himlTemp;
127 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
129 himlTemp = infoPtr->himl;
130 infoPtr->himl = (HIMAGELIST)lParam;
132 return (LRESULT)himlTemp;
136 static LRESULT
137 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
139 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); */
141 FIXME("(%p): stub\n", (LPVOID)lParam);
143 return TRUE;
147 /* << COMBOEX_SetItem32W >> */
150 inline static LRESULT
151 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
153 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
155 FIXME("(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
157 if (infoPtr->hwndCombo)
158 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
160 return 0;
164 static LRESULT
165 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
167 COMBOEX_INFO *infoPtr;
168 DWORD dwComboStyle;
170 /* allocate memory for info structure */
171 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
172 if (infoPtr == NULL) {
173 ERR("could not allocate info memory!\n");
174 return 0;
177 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
180 /* initialize info structure */
183 /* create combo box */
184 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
185 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
187 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
188 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
189 0, 0, 0, 0, hwnd, (HMENU)1,
190 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
192 return 0;
196 static LRESULT
197 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
199 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
202 if (infoPtr->hwndCombo)
203 DestroyWindow (infoPtr->hwndCombo);
208 /* free comboex info data */
209 COMCTL32_Free (infoPtr);
210 SetWindowLongA (hwnd, 0, 0);
211 return 0;
215 static LRESULT
216 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
218 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
219 RECT rect;
221 GetClientRect (hwnd, &rect);
223 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
224 rect.bottom - rect.top, TRUE);
226 return 0;
230 static LRESULT WINAPI
231 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
233 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
234 if (!COMBOEX_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
235 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
237 switch (uMsg)
239 /* case CBEM_DELETEITEM: */
241 case CBEM_GETCOMBOCONTROL:
242 return COMBOEX_GetComboControl (hwnd, wParam, lParam);
244 case CBEM_GETEDITCONTROL:
245 return COMBOEX_GetEditControl (hwnd, wParam, lParam);
247 case CBEM_GETEXTENDEDSTYLE:
248 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
250 case CBEM_GETIMAGELIST:
251 return COMBOEX_GetImageList (hwnd, wParam, lParam);
253 /* case CBEM_GETITEM32A:
254 case CBEM_GETITEM32W:
255 case CBEM_GETUNICODEFORMAT:
256 case CBEM_HASEDITCHANGED:
259 case CBEM_INSERTITEMA:
260 return COMBOEX_InsertItemA (hwnd, wParam, lParam);
262 /* case CBEM_INSERTITEM32W: */
264 case CBEM_SETEXTENDEDSTYLE:
265 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
267 case CBEM_SETIMAGELIST:
268 return COMBOEX_SetImageList (hwnd, wParam, lParam);
270 case CBEM_SETITEMA:
271 return COMBOEX_SetItemA (hwnd, wParam, lParam);
273 /* case CBEM_SETITEM32W:
274 case CBEM_SETUNICODEFORMAT:
277 case CB_DELETESTRING:
278 case CB_FINDSTRINGEXACT:
279 case CB_GETCOUNT:
280 case CB_GETCURSEL:
281 case CB_GETDROPPEDCONTROLRECT:
282 case CB_GETDROPPEDSTATE:
283 case CB_GETITEMDATA:
284 case CB_GETITEMHEIGHT:
285 case CB_GETLBTEXT:
286 case CB_GETLBTEXTLEN:
287 case CB_GETEXTENDEDUI:
288 case CB_LIMITTEXT:
289 case CB_RESETCONTENT:
290 case CB_SELECTSTRING:
291 case CB_SETCURSEL:
292 case CB_SETDROPPEDWIDTH:
293 case CB_SETEXTENDEDUI:
294 case CB_SETITEMDATA:
295 case CB_SETITEMHEIGHT:
296 case CB_SHOWDROPDOWN:
297 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
300 case WM_CREATE:
301 return COMBOEX_Create (hwnd, wParam, lParam);
303 case WM_DESTROY:
304 return COMBOEX_Destroy (hwnd, wParam, lParam);
306 case WM_SIZE:
307 return COMBOEX_Size (hwnd, wParam, lParam);
309 default:
310 if (uMsg >= WM_USER)
311 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
312 uMsg, wParam, lParam);
313 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
315 return 0;
319 VOID
320 COMBOEX_Register (void)
322 WNDCLASSA wndClass;
324 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
325 wndClass.style = CS_GLOBALCLASS;
326 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
327 wndClass.cbClsExtra = 0;
328 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
329 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
330 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
331 wndClass.lpszClassName = WC_COMBOBOXEXA;
333 RegisterClassA (&wndClass);
337 VOID
338 COMBOEX_Unregister (void)
340 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);