source: trunk/src/comctl32/comboex.cpp@ 3585

Last change on this file since 3585 was 3585, checked in by cbratschi, 25 years ago

merged with Corel WINE 20000513, added new DPA_* functions

File size: 7.2 KB
Line 
1/* $Id: comboex.cpp,v 1.4 2000-05-22 17:25:07 cbratschi Exp $ */
2/*
3 * ComboBoxEx control
4 *
5 * Copyright 1998, 1999 Eric Kohl
6 * Copyright 1999 Achim Hasenmueller
7 *
8 * NOTES
9 * This is just a dummy control. An author is needed! Any volunteers?
10 * I will only improve this control once in a while.
11 * Eric <ekohl@abo.rhein-zeitung.de>
12 *
13 * TODO:
14 * - All messages.
15 * - All notifications.
16 *
17 * FIXME:
18 * - should include "combo.h"
19 */
20
21/*
22 - Corel WINE 20000513 level
23*/
24
25#include "winbase.h"
26#include "commctrl.h"
27#include "comctl32.h"
28#include "ccbase.h"
29#include "comboex.h"
30
31
32#define ID_CB_EDIT 1001
33
34#define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)getInfoPtr(hwnd))
35
36
37/* << COMBOEX_DeleteItem >> */
38
39
40static LRESULT
41COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
42{
43 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
44
45 return (LRESULT)infoPtr->hwndCombo;
46}
47
48
49static LRESULT
50COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
51{
52 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
53
54 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
55 return 0;
56
57 return (LRESULT)GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT);
58}
59
60
61static LRESULT
62COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
63{
64 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
65
66 return (LRESULT)infoPtr->dwExtStyle;
67}
68
69
70static LRESULT
71COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
72{
73 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
74
75 return (LRESULT)infoPtr->himl;
76}
77
78
79
80
81static LRESULT COMBOEX_InsertItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
82{
83 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); */
84
85// FIXME (comboex, "(0x%08x 0x%08lx)\n", wParam, lParam);
86
87 return -1;
88}
89
90
91
92static LRESULT
93COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
94{
95 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
96 DWORD dwTemp;
97
98 dwTemp = infoPtr->dwExtStyle;
99
100 if ((DWORD)wParam) {
101 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
102 }
103 else
104 infoPtr->dwExtStyle = (DWORD)lParam;
105
106 /* FIXME: repaint?? */
107
108 return (LRESULT)dwTemp;
109}
110
111
112static LRESULT
113COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
114{
115 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
116 HIMAGELIST himlTemp;
117
118 himlTemp = infoPtr->himl;
119 infoPtr->himl = (HIMAGELIST)lParam;
120
121 return (LRESULT)himlTemp;
122}
123
124
125static LRESULT COMBOEX_SetItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
126{
127 /* COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); */
128
129// FIXME (comboex, "(%p): stub\n", (LPVOID)lParam);
130
131 return TRUE;
132}
133
134
135static LRESULT
136COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
137{
138 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
139
140// FIXME (comboex, "(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
141
142 if (infoPtr->hwndCombo)
143 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
144
145 return 0;
146}
147
148
149static LRESULT
150COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
151{
152 COMBOEX_INFO *infoPtr;
153 DWORD dwComboStyle;
154
155 /* allocate memory for info structure */
156 infoPtr = (COMBOEX_INFO*)initControl(hwnd,sizeof(COMBOEX_INFO));
157 if (infoPtr == NULL) {
158// ERR (comboex, "could not allocate info memory!\n");
159 return 0;
160 }
161
162 /* initialize info structure */
163
164
165 /* create combo box */
166 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
167 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
168
169 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
170 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
171 0, 0, 0, 0, hwnd, (HMENU)1,
172 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
173
174 return 0;
175}
176
177
178static LRESULT
179COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
180{
181 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
182
183 /* free comboex info data */
184 doneControl(hwnd);
185
186 return 0;
187}
188
189
190static LRESULT
191COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
192{
193 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
194 RECT rect;
195
196 GetClientRect (hwnd, &rect);
197
198 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
199 rect.bottom - rect.top, TRUE);
200
201 return 0;
202}
203
204
205static LRESULT WINAPI
206COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
207{
208 switch (uMsg)
209 {
210/* case CBEM_DELETEITEM: */
211
212 case CBEM_GETCOMBOCONTROL:
213 return COMBOEX_GetComboControl (hwnd, wParam, lParam);
214
215 case CBEM_GETEDITCONTROL:
216 return COMBOEX_GetEditControl (hwnd, wParam, lParam);
217
218 case CBEM_GETEXTENDEDSTYLE:
219 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
220
221 case CBEM_GETIMAGELIST:
222 return COMBOEX_GetImageList (hwnd, wParam, lParam);
223
224/* case CBEM_GETITEM32A:
225 case CBEM_GETITEM32W:
226 case CBEM_HASEDITCHANGED:
227*/
228
229 case CBEM_INSERTITEMA:
230 return COMBOEX_InsertItem(hwnd,wParam,lParam,FALSE);
231
232 case CBEM_INSERTITEMW:
233 return COMBOEX_InsertItem(hwnd,wParam,lParam,TRUE);
234
235 case CBEM_SETEXTENDEDSTYLE:
236 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
237
238 case CBEM_SETIMAGELIST:
239 return COMBOEX_SetImageList (hwnd, wParam, lParam);
240
241 case CBEM_SETITEMA:
242 return COMBOEX_SetItem(hwnd,wParam,lParam,FALSE);
243
244 case CBEM_SETITEMW:
245 return COMBOEX_SetItem(hwnd,wParam,lParam,TRUE);
246
247 case CB_DELETESTRING:
248 case CB_FINDSTRINGEXACT:
249 case CB_GETCOUNT:
250 case CB_GETCURSEL:
251 case CB_GETDROPPEDCONTROLRECT:
252 case CB_GETDROPPEDSTATE:
253 case CB_GETITEMDATA:
254 case CB_GETITEMHEIGHT:
255 case CB_GETLBTEXT:
256 case CB_GETLBTEXTLEN:
257 case CB_GETEXTENDEDUI:
258 case CB_LIMITTEXT:
259 case CB_RESETCONTENT:
260 case CB_SELECTSTRING:
261 case CB_SETCURSEL:
262 case CB_SETDROPPEDWIDTH:
263 case CB_SETEXTENDEDUI:
264 case CB_SETITEMDATA:
265 case CB_SETITEMHEIGHT:
266 case CB_SHOWDROPDOWN:
267 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
268
269
270 case WM_CREATE:
271 return COMBOEX_Create (hwnd, wParam, lParam);
272
273 case WM_DESTROY:
274 return COMBOEX_Destroy (hwnd, wParam, lParam);
275
276 case WM_SIZE:
277 return COMBOEX_Size (hwnd, wParam, lParam);
278
279 default:
280// if (uMsg >= WM_USER)
281// ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n",
282// uMsg, wParam, lParam);
283 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
284 }
285 return 0;
286}
287
288
289VOID
290COMBOEX_Register (VOID)
291{
292 WNDCLASSA wndClass;
293
294 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
295 wndClass.style = CS_GLOBALCLASS;
296 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
297 wndClass.cbClsExtra = 0;
298 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
299 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
300 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
301 wndClass.lpszClassName = WC_COMBOBOXEXA;
302
303 RegisterClassA (&wndClass);
304}
305
306
307VOID
308COMBOEX_Unregister (VOID)
309{
310 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);
311}
312
Note: See TracBrowser for help on using the repository browser.