4 * Copyright 1998, 1999 Eric Kohl
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>
13 * - All notifications.
16 * - should include "combo.h"
21 #include "debugtools.h"
23 DEFAULT_DEBUG_CHANNEL(comboex
);
32 #define ID_CB_EDIT 1001
34 #define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
37 /* << COMBOEX_DeleteItem >> */
41 COMBOEX_GetComboControl (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
43 COMBOEX_INFO
*infoPtr
= COMBOEX_GetInfoPtr (hwnd
);
47 return (LRESULT
)infoPtr
->hwndCombo
;
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
)
59 TRACE("-- 0x%x\n", GetDlgItem (infoPtr
->hwndCombo
, ID_CB_EDIT
));
61 return (LRESULT
)GetDlgItem (infoPtr
->hwndCombo
, ID_CB_EDIT
);
66 COMBOEX_GetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
68 COMBOEX_INFO
*infoPtr
= COMBOEX_GetInfoPtr (hwnd
);
70 return (LRESULT
)infoPtr
->dwExtStyle
;
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
;
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
);
100 COMBOEX_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
102 COMBOEX_INFO
*infoPtr
= COMBOEX_GetInfoPtr (hwnd
);
105 TRACE("(0x%08x 0x%08lx)\n", wParam
, lParam
);
107 dwTemp
= infoPtr
->dwExtStyle
;
110 infoPtr
->dwExtStyle
= (infoPtr
->dwExtStyle
& ~(DWORD
)wParam
) | (DWORD
)lParam
;
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
);
127 TRACE("(0x%08x 0x%08lx)\n", wParam
, lParam
);
129 himlTemp
= infoPtr
->himl
;
130 infoPtr
->himl
= (HIMAGELIST
)lParam
;
132 return (LRESULT
)himlTemp
;
137 COMBOEX_SetItemA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
139 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); */
141 FIXME("(%p): stub\n", (LPVOID
)lParam
);
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
);
165 COMBOEX_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
167 COMBOEX_INFO
*infoPtr
;
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");
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
);
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);
216 COMBOEX_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
218 COMBOEX_INFO
*infoPtr
= COMBOEX_GetInfoPtr (hwnd
);
221 GetClientRect (hwnd
, &rect
);
223 MoveWindow (infoPtr
->hwndCombo
, 0, 0, rect
.right
-rect
.left
,
224 rect
.bottom
- rect
.top
, TRUE
);
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
);
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
);
271 return COMBOEX_SetItemA (hwnd
, wParam
, lParam
);
273 /* case CBEM_SETITEM32W:
274 case CBEM_SETUNICODEFORMAT:
277 case CB_DELETESTRING
:
278 case CB_FINDSTRINGEXACT
:
281 case CB_GETDROPPEDCONTROLRECT
:
282 case CB_GETDROPPEDSTATE
:
284 case CB_GETITEMHEIGHT
:
286 case CB_GETLBTEXTLEN
:
287 case CB_GETEXTENDEDUI
:
289 case CB_RESETCONTENT
:
290 case CB_SELECTSTRING
:
292 case CB_SETDROPPEDWIDTH
:
293 case CB_SETEXTENDEDUI
:
295 case CB_SETITEMHEIGHT
:
296 case CB_SHOWDROPDOWN
:
297 return COMBOEX_Forward (hwnd
, uMsg
, wParam
, lParam
);
301 return COMBOEX_Create (hwnd
, wParam
, lParam
);
304 return COMBOEX_Destroy (hwnd
, wParam
, lParam
);
307 return COMBOEX_Size (hwnd
, wParam
, lParam
);
311 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
312 uMsg
, wParam
, lParam
);
313 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
320 COMBOEX_Register (void)
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
);
338 COMBOEX_Unregister (void)
340 UnregisterClassA (WC_COMBOBOXEXA
, (HINSTANCE
)NULL
);