Release 980913
[wine/multimedia.git] / dlls / comctl32 / comboex.c
blob7c7dc900b0298ebfcbed16d311893a9920db2aec
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 "windows.h"
20 #include "commctrl.h"
21 #include "comboex.h"
22 #include "win.h"
23 #include "debug.h"
25 #define ID_CB_EDIT 1001
27 #define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)wndPtr->wExtra[0])
30 // << COMBOEX_DeleteItem >>
33 __inline__ static LRESULT
34 COMBOEX_GetComboControl (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
36 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
38 TRACE (comboex, "\n");
40 return (LRESULT)infoPtr->hwndCombo;
44 __inline__ static LRESULT
45 COMBOEX_GetEditControl (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
47 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
49 if ((wndPtr->dwStyle & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
50 return 0;
52 FIXME (comboex, "-- 0x%x\n", GetDlgItem32 (infoPtr->hwndCombo, ID_CB_EDIT));
54 return (LRESULT)GetDlgItem32 (infoPtr->hwndCombo, ID_CB_EDIT);
58 __inline__ static LRESULT
59 COMBOEX_GetExtendedStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
61 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
63 return (LRESULT)infoPtr->dwExtStyle;
67 __inline__ static LRESULT
68 COMBOEX_GetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
70 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
72 TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
74 return (LRESULT)infoPtr->himl;
80 static LRESULT
81 COMBOEX_InsertItem32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
83 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
85 FIXME (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
87 return -1;
92 static LRESULT
93 COMBOEX_SetExtendedStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
95 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
96 DWORD dwTemp;
98 TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
100 dwTemp = infoPtr->dwExtStyle;
102 if ((DWORD)wParam) {
103 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
105 else
106 infoPtr->dwExtStyle = (DWORD)lParam;
108 /* FIXME: repaint?? */
110 return (LRESULT)dwTemp;
114 __inline__ static LRESULT
115 COMBOEX_SetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
117 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
118 HIMAGELIST himlTemp;
120 TRACE (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
122 himlTemp = infoPtr->himl;
123 infoPtr->himl = (HIMAGELIST)lParam;
125 return (LRESULT)himlTemp;
131 static LRESULT
132 COMBOEX_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
134 COMBOEX_INFO *infoPtr;
135 DWORD dwComboStyle;
137 /* allocate memory for info structure */
138 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
139 wndPtr->wExtra[0] = (DWORD)infoPtr;
141 if (infoPtr == NULL) {
142 ERR (listview, "could not allocate info memory!\n");
143 return 0;
146 if ((COMBOEX_INFO*)wndPtr->wExtra[0] != infoPtr) {
147 ERR (listview, "pointer assignment error!\n");
148 return 0;
152 /* initialize info structure */
155 /* create combo box */
156 dwComboStyle =
157 wndPtr->dwStyle & (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
159 infoPtr->hwndCombo =
160 CreateWindow32A ("ComboBox", "",
161 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
162 0, 0, 0, 0, wndPtr->hwndSelf, (HMENU32)1,
163 wndPtr->hInstance, NULL);
166 return 0;
170 static LRESULT
171 COMBOEX_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
173 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
176 if (infoPtr->hwndCombo)
177 DestroyWindow32 (infoPtr->hwndCombo);
182 /* free comboex info data */
183 COMCTL32_Free (infoPtr);
185 return 0;
189 static LRESULT
190 COMBOEX_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
192 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr(wndPtr);
193 RECT32 rect;
195 GetClientRect32 (wndPtr->hwndSelf, &rect);
197 MoveWindow32 (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
198 rect.bottom - rect.top, TRUE);
200 return 0;
204 LRESULT WINAPI
205 COMBOEX_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
207 WND *wndPtr = WIN_FindWndPtr(hwnd);
209 switch (uMsg)
211 // case CBEM_DELETEITEM:
213 case CBEM_GETCOMBOCONTROL:
214 return COMBOEX_GetComboControl (wndPtr, wParam, lParam);
216 case CBEM_GETEDITCONTROL:
217 return COMBOEX_GetEditControl (wndPtr, wParam, lParam);
219 case CBEM_GETEXTENDEDSTYLE:
220 return COMBOEX_GetExtendedStyle (wndPtr, wParam, lParam);
222 case CBEM_GETIMAGELIST:
223 return COMBOEX_GetImageList (wndPtr, wParam, lParam);
225 // case CBEM_GETITEM32A:
226 // case CBEM_GETITEM32W:
227 // case CBEM_GETUNICODEFORMAT:
228 // case CBEM_HASEDITCHANGED:
230 case CBEM_INSERTITEM32A:
231 return COMBOEX_InsertItem32A (wndPtr, wParam, lParam);
233 // case CBEM_INSERTITEM32W:
235 case CBEM_SETEXTENDEDSTYLE:
236 return COMBOEX_SetExtendedStyle (wndPtr, wParam, lParam);
238 case CBEM_SETIMAGELIST:
239 return COMBOEX_SetImageList (wndPtr, wParam, lParam);
241 // case CBEM_SETITEM32A:
242 // case CBEM_SETITEM32W:
243 // case CBEM_SETUNICODEFORMAT:
246 case WM_CREATE:
247 return COMBOEX_Create (wndPtr, wParam, lParam);
249 case WM_DESTROY:
250 return COMBOEX_Destroy (wndPtr, wParam, lParam);
252 case WM_SIZE:
253 return COMBOEX_Size (wndPtr, wParam, lParam);
255 default:
256 if (uMsg >= WM_USER)
257 ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n",
258 uMsg, wParam, lParam);
259 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
261 return 0;
265 void
266 COMBOEX_Register (void)
268 WNDCLASS32A wndClass;
270 if (GlobalFindAtom32A (WC_COMBOBOXEX32A)) return;
272 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
273 wndClass.style = CS_GLOBALCLASS;
274 wndClass.lpfnWndProc = (WNDPROC32)COMBOEX_WindowProc;
275 wndClass.cbClsExtra = 0;
276 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
277 wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
278 wndClass.hbrBackground = (HBRUSH32)(COLOR_WINDOW + 1);
279 wndClass.lpszClassName = WC_COMBOBOXEX32A;
281 RegisterClass32A (&wndClass);