Release 941210
[wine/multimedia.git] / controls / combo.c
blobb5c9186fb6dce9f450e580e9dbece54ed7647806
1 /*
2 * Interface code to COMBOBOX widget
4 * Copyright Martin Ayotte, 1993
6 static char Copyright[] = "Copyright Martin Ayotte, 1993";
7 */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
14 #include "windows.h"
15 #include "combo.h"
16 #include "user.h"
17 #include "heap.h"
18 #include "win.h"
19 #include "prototypes.h"
20 #include "stddebug.h"
21 /* #define DEBUG_COMBO */
22 #include "debug.h"
23 #include "graphics.h"
25 HBITMAP hComboBit = 0;
27 LPHEADCOMBO ComboGetStorageHeader(HWND hwnd);
28 int CreateComboStruct(HWND hwnd);
29 void ComboBoxStaticOwnerDraw(HWND hWnd, LPHEADCOMBO lphc);
32 /***********************************************************************
33 * ComboWndProc
35 LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
37 RECT rect;
38 int y, count;
39 int width, height;
40 WND *wndPtr;
41 LPHEADCOMBO lphc;
42 HDC hDC;
43 BITMAP bm;
44 char str[128];
45 PAINTSTRUCT paintstruct;
46 LPDRAWITEMSTRUCT lpdis;
47 DWORD dwStyle;
48 switch(message) {
49 case WM_CREATE:
50 wndPtr = WIN_FindWndPtr(hwnd);
51 if (wndPtr == NULL) return 0;
52 dprintf_combo(stddeb,"Combo WM_CREATE %d !\n", hwnd);
53 if (hComboBit == (HBITMAP)NULL)
54 hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO));
55 GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
56 wndPtr->dwStyle &= 0xFFFFFFFFL ^ (WS_VSCROLL | WS_HSCROLL);
57 GetWindowRect(hwnd, &rect);
58 width = rect.right - rect.left;
59 height = rect.bottom - rect.top;
60 if (height < bm.bmHeight) height = bm.bmHeight;
61 /* SetWindowPos(hwnd, 0, 0, 0, width + bm.bmHeight, bm.bmHeight,
62 SWP_NOMOVE | SWP_NOZORDER); */
63 SetWindowPos(hwnd, 0, 0, 0, width, bm.bmHeight,
64 SWP_NOMOVE | SWP_NOZORDER);
65 CreateComboStruct(hwnd);
66 lphc = ComboGetStorageHeader(hwnd);
67 if (lphc == NULL) return 0;
68 /* SetRect(&lphc->RectEdit, 0, 0, width - 2, bm.bmHeight); */
69 SetRect(&lphc->RectEdit, 0, 0, width - bm.bmHeight, bm.bmHeight);
70 if (wndPtr->dwStyle & CBS_DROPDOWNLIST) {
71 if ((wndPtr->dwStyle & CBS_OWNERDRAWFIXED) == CBS_OWNERDRAWFIXED ||
72 (wndPtr->dwStyle & CBS_OWNERDRAWVARIABLE) == CBS_OWNERDRAWVARIABLE)
73 lphc->hWndEdit = 0;
74 else
75 lphc->hWndEdit = CreateWindow("STATIC", "",
76 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
77 0, 0, width - bm.bmHeight, bm.bmHeight,
78 hwnd, 1, wndPtr->hInstance, 0L);
80 else {
81 /* lphc->hWndEdit = CreateWindow("EDIT", "", */
82 lphc->hWndEdit = CreateWindow("STATIC", "",
83 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
84 0, 0, width - bm.bmHeight, bm.bmHeight,
85 hwnd, 1, wndPtr->hInstance, 0L);
87 dwStyle = WS_POPUP | WS_BORDER | WS_VSCROLL | LBS_NOTIFY;
88 if ((wndPtr->dwStyle & CBS_HASSTRINGS) == CBS_HASSTRINGS)
89 dwStyle |= LBS_HASSTRINGS;
90 if ((wndPtr->dwStyle & CBS_SORT) == CBS_SORT)
91 dwStyle |= LBS_SORT;
92 if ((wndPtr->dwStyle & CBS_OWNERDRAWFIXED) == CBS_OWNERDRAWFIXED)
93 dwStyle |= LBS_OWNERDRAWFIXED;
94 if ((wndPtr->dwStyle & CBS_OWNERDRAWVARIABLE) == CBS_OWNERDRAWVARIABLE)
95 dwStyle |= LBS_OWNERDRAWVARIABLE;
96 lphc->hWndLBox = CreateWindow("LISTBOX", "", dwStyle,
97 rect.left, rect.top + bm.bmHeight,
98 width, height, wndPtr->hwndParent, 0,
99 wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd));
100 ShowWindow(lphc->hWndLBox, SW_HIDE);
101 dprintf_combo(stddeb,"Combo Creation LBox=%X!\n", lphc->hWndLBox);
102 return 0;
103 case WM_DESTROY:
104 lphc = ComboGetStorageHeader(hwnd);
105 if (lphc == 0) return 0;
107 if (lphc->hWndEdit != 0) DestroyWindow(lphc->hWndEdit);
109 DestroyWindow(lphc->hWndLBox);
110 free(lphc);
112 *((LPHEADCOMBO *)&wndPtr->wExtra[1]) = 0;
113 printf("Combo WM_DESTROY after clearing wExtra !\n");
115 dprintf_combo(stddeb,"Combo WM_DESTROY %p !\n", lphc);
116 return DefWindowProc( hwnd, message, wParam, lParam );
117 case WM_SHOWWINDOW:
118 dprintf_combo(stddeb,"ComboBox WM_SHOWWINDOW hWnd=%04X !\n",
119 hwnd);
120 if (!(wParam == 0 && lParam == 0L)) {
121 InvalidateRect(hwnd, NULL, TRUE);
123 break;
125 case WM_COMMAND:
126 wndPtr = WIN_FindWndPtr(hwnd);
127 lphc = ComboGetStorageHeader(hwnd);
128 if (lphc == NULL || wndPtr == NULL) return 0;
129 if (LOWORD(lParam) == lphc->hWndLBox) {
130 switch(HIWORD(lParam)) {
131 case LBN_SELCHANGE:
132 lphc->dwState = lphc->dwState & (CB_SHOWDROPDOWN ^ 0xFFFFFFFFL);
133 ShowWindow(lphc->hWndLBox, SW_HIDE);
134 y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
135 if (y != LB_ERR) {
136 SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
137 if (lphc->hWndEdit != 0)
138 SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
139 else {
140 InvalidateRect(hwnd, NULL, TRUE);
141 UpdateWindow(hwnd);
144 SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
145 MAKELONG(hwnd, CBN_SELCHANGE));
146 break;
147 case LBN_DBLCLK:
148 SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
149 MAKELONG(hwnd, CBN_DBLCLK));
150 break;
153 break;
154 case WM_LBUTTONDOWN:
155 dprintf_combo(stddeb,"Combo WM_LBUTTONDOWN wParam=%x lParam=%lX !\n", wParam, lParam);
156 GetClientRect(hwnd, &rect);
157 rect.left = rect.right - (rect.bottom - rect.top);
158 hDC = GetDC(hwnd);
159 InflateRect(&rect, -1, -1);
160 GRAPH_DrawReliefRect(hDC, &rect, 1, 1, TRUE);
161 ReleaseDC(hwnd, hDC);
162 wndPtr = WIN_FindWndPtr(hwnd);
163 lphc = ComboGetStorageHeader(hwnd);
164 if (lphc == NULL) return 0;
165 lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
166 if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
167 ShowWindow(lphc->hWndLBox, SW_SHOW);
168 SetFocus(lphc->hWndLBox);
170 else {
171 dprintf_combo(stddeb,"before Combo Restore Focus !\n");
172 SetFocus(lphc->hWndEdit);
173 dprintf_combo(stddeb,"before Combo List Hide !\n");
174 ShowWindow(lphc->hWndLBox, SW_HIDE);
175 dprintf_combo(stddeb,"before Combo List GetCurSel !\n");
176 y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
177 if (y != LB_ERR) {
178 dprintf_combo(stddeb,"before Combo List GetText !\n");
179 SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
180 SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
182 dprintf_combo(stddeb,"End of Combo List Hide !\n");
184 break;
185 case WM_LBUTTONUP:
186 dprintf_combo(stddeb,"Combo WM_LBUTTONUP wParam=%x lParam=%lX !\n", wParam, lParam);
187 GetClientRect(hwnd, &rect);
188 rect.left = rect.right - (rect.bottom - rect.top);
189 hDC = GetDC(hwnd);
190 InflateRect(&rect, -1, -1);
191 GRAPH_DrawReliefRect(hDC, &rect, 1, 1, FALSE);
192 ReleaseDC(hwnd, hDC);
193 break;
194 case WM_KEYDOWN:
195 wndPtr = WIN_FindWndPtr(hwnd);
196 lphc = ComboGetStorageHeader(hwnd);
197 if (lphc == NULL || wndPtr == NULL) return 0;
198 y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
199 count = SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L);
200 dprintf_combo(stddeb,"COMBOBOX // GetKeyState(VK_MENU)=%d\n", GetKeyState(VK_MENU));
201 if (GetKeyState(VK_MENU) < 0) {
202 lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
203 if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
204 GetWindowRect(hwnd, &rect);
205 SetWindowPos(lphc->hWndLBox, 0, rect.left, rect.bottom, 0, 0,
206 SWP_NOREDRAW | SWP_NOSIZE);
207 SetWindowPos(lphc->hWndLBox, 0, 0, 0, 0, 0, SWP_SHOWWINDOW |
208 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
209 SetFocus(lphc->hWndLBox);
211 else {
212 ShowWindow(lphc->hWndLBox, SW_HIDE);
213 y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
214 if (y != LB_ERR) {
215 SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
216 if (lphc->hWndEdit != 0)
217 SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
221 else {
222 switch(wParam) {
223 case VK_HOME:
224 y = 0;
225 break;
226 case VK_END:
227 y = count - 1;
228 break;
229 case VK_UP:
230 y--;
231 break;
232 case VK_DOWN:
233 y++;
234 break;
236 if (y < 0) y = 0;
237 if (y >= count) y = count - 1;
238 lphc->LastSel = y;
239 SendMessage(lphc->hWndLBox, LB_SETCURSEL, y, 0L);
240 SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
241 if (lphc->hWndEdit != 0)
242 SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
243 SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
244 MAKELONG(hwnd, CBN_SELCHANGE));
246 break;
247 case WM_MEASUREITEM:
248 dprintf_combo(stddeb,"ComboBoxWndProc WM_MEASUREITEM !\n");
249 return(SendMessage(GetParent(hwnd), WM_MEASUREITEM, wParam, lParam));
250 case WM_CTLCOLOR:
251 return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam));
252 case WM_SETREDRAW:
253 dprintf_combo(stddeb,"ComboBoxWndProc WM_SETREDRAW hWnd=%04X w=%04X !\n", hwnd, wParam);
254 lphc = ComboGetStorageHeader(hwnd);
255 if (lphc == NULL) return 0;
256 lphc->bRedrawFlag = wParam;
257 break;
258 case WM_DRAWITEM:
259 dprintf_combo(stddeb,"ComboBoxWndProc // WM_DRAWITEM w=%04X l=%08lX\n", wParam, lParam);
260 wndPtr = WIN_FindWndPtr(hwnd);
261 if (wndPtr == NULL) break;
262 lpdis = (LPDRAWITEMSTRUCT)lParam;
263 if (lpdis == NULL) break;
264 lpdis->CtlType = ODT_COMBOBOX;
265 lpdis->CtlID = wndPtr->wIDmenu;
266 return(SendMessage(GetParent(hwnd), WM_DRAWITEM, wParam, lParam));
267 case WM_PAINT:
268 GetClientRect(hwnd, &rect);
269 hDC = BeginPaint(hwnd, &paintstruct);
270 if (hComboBit != 0) {
271 GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
272 GRAPH_DrawBitmap( hDC, hComboBit,
273 rect.right - bm.bmWidth, 0,
274 0, 0, bm.bmWidth, bm.bmHeight,
275 SRCCOPY );
277 EndPaint(hwnd, &paintstruct);
278 lphc = ComboGetStorageHeader(hwnd);
279 if (lphc == NULL) return 0;
280 if (lphc->hWndEdit != 0) {
281 InvalidateRect(lphc->hWndEdit, NULL, TRUE);
282 UpdateWindow(lphc->hWndEdit);
284 else {
285 ComboBoxStaticOwnerDraw(hwnd, lphc);
287 if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
288 InvalidateRect(lphc->hWndLBox, NULL, TRUE);
289 UpdateWindow(lphc->hWndLBox);
291 break;
292 case WM_SETFOCUS:
293 lphc = ComboGetStorageHeader(hwnd);
294 if (lphc == NULL) return 0;
295 if (lphc->hWndEdit != 0)
296 SetFocus(lphc->hWndEdit);
297 break;
298 case WM_KILLFOCUS:
299 lphc = ComboGetStorageHeader(hwnd);
300 if (lphc == NULL) return 0;
301 ShowWindow(lphc->hWndLBox, SW_HIDE);
302 y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
303 if (y != LB_ERR) {
304 SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
305 if (lphc->hWndEdit != 0)
306 SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
308 break;
309 case CB_ADDSTRING:
310 dprintf_combo(stddeb,"CB_ADDSTRING '%s' !\n", (LPSTR)lParam);
311 lphc = ComboGetStorageHeader(hwnd);
312 if (lphc == NULL) return 0;
313 return(SendMessage(lphc->hWndLBox, LB_ADDSTRING, wParam, lParam));
314 case CB_GETLBTEXT:
315 dprintf_combo(stddeb,"CB_GETLBTEXT #%u !\n", wParam);
316 lphc = ComboGetStorageHeader(hwnd);
317 if (lphc == NULL) return 0;
318 return(SendMessage(lphc->hWndLBox, LB_GETTEXT, wParam, lParam));
319 case CB_GETLBTEXTLEN:
320 dprintf_combo(stddeb,"CB_GETLBTEXTLEN !\n");
321 lphc = ComboGetStorageHeader(hwnd);
322 if (lphc == NULL) return 0;
323 return(SendMessage(lphc->hWndLBox, LB_GETTEXTLEN, wParam, lParam));
324 case CB_INSERTSTRING:
325 dprintf_combo(stddeb,"CB_INSERTSTRING '%s' !\n",(LPSTR)lParam);
326 lphc = ComboGetStorageHeader(hwnd);
327 if (lphc == NULL) return 0;
328 return(SendMessage(lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam));
329 case CB_DELETESTRING:
330 dprintf_combo(stddeb,"CB_DELETESTRING #%u !\n", wParam);
331 lphc = ComboGetStorageHeader(hwnd);
332 if (lphc == NULL) return 0;
333 return(SendMessage(lphc->hWndLBox, LB_DELETESTRING, wParam, 0L));
334 case CB_RESETCONTENT:
335 dprintf_combo(stddeb,"CB_RESETCONTENT !\n");
336 lphc = ComboGetStorageHeader(hwnd);
337 if (lphc == NULL) return 0;
338 return(SendMessage(lphc->hWndLBox, LB_RESETCONTENT, 0, 0L));
339 case CB_DIR:
340 dprintf_combo(stddeb,"ComboBox CB_DIR !\n");
341 lphc = ComboGetStorageHeader(hwnd);
342 if (lphc == NULL) return 0;
343 return(SendMessage(lphc->hWndLBox, LB_DIR, wParam, lParam));
344 case CB_FINDSTRING:
345 lphc = ComboGetStorageHeader(hwnd);
346 return(SendMessage(lphc->hWndLBox, LB_FINDSTRING, wParam, lParam));
347 case CB_GETCOUNT:
348 lphc = ComboGetStorageHeader(hwnd);
349 if (lphc == NULL) return 0;
350 return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L));
351 case CB_GETCURSEL:
352 dprintf_combo(stddeb,"ComboBox CB_GETCURSEL !\n");
353 lphc = ComboGetStorageHeader(hwnd);
354 if (lphc == NULL) return 0;
355 return(SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L));
356 case CB_SETCURSEL:
357 dprintf_combo(stddeb,"ComboBox CB_SETCURSEL wParam=%X !\n", wParam);
358 lphc = ComboGetStorageHeader(hwnd);
359 if (lphc == NULL) return 0;
360 return(SendMessage(lphc->hWndLBox, LB_SETCURSEL, wParam, 0L));
361 case CB_GETEDITSEL:
362 dprintf_combo(stddeb,"ComboBox CB_GETEDITSEL !\n");
363 lphc = ComboGetStorageHeader(hwnd);
364 if (lphc == NULL) return 0;
365 /* if (lphc->hWndEdit != 0)
366 return(SendMessage(lphc->hWndEdit, EM_GETSEL, 0, 0L)); */
367 break;
368 case CB_SETEDITSEL:
369 dprintf_combo(stddeb,"ComboBox CB_SETEDITSEL lParam=%lX !\n",
370 lParam);
371 lphc = ComboGetStorageHeader(hwnd);
372 if (lphc == NULL) return 0;
373 /* if (lphc->hWndEdit != 0)
374 return(SendMessage(lphc->hWndEdit, EM_SETSEL, 0, lParam)); */
375 break;
376 case CB_SELECTSTRING:
377 dprintf_combo(stddeb,"ComboBox CB_SELECTSTRING !\n");
378 lphc = ComboGetStorageHeader(hwnd);
379 if (lphc == NULL) return 0;
380 break;
381 case CB_SHOWDROPDOWN:
382 dprintf_combo(stddeb,"ComboBox CB_SHOWDROPDOWN !\n");
383 lphc = ComboGetStorageHeader(hwnd);
384 if (lphc == NULL) return 0;
385 wndPtr = WIN_FindWndPtr(hwnd);
386 lphc->dwState = lphc->dwState | CB_SHOWDROPDOWN;
387 if (wParam != 0) {
388 GetWindowRect(hwnd, &rect);
389 SetWindowPos(lphc->hWndLBox, 0, rect.left, rect.bottom, 0, 0,
390 SWP_NOREDRAW | SWP_NOSIZE);
391 SetWindowPos(lphc->hWndLBox, 0, 0, 0, 0, 0, SWP_SHOWWINDOW |
392 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
394 else {
395 lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
396 ShowWindow(lphc->hWndLBox, SW_HIDE);
397 SendMessage(GetParent(hwnd), WM_COMMAND, wndPtr->wIDmenu,
398 MAKELONG(hwnd, CBN_DROPDOWN));
400 break;
401 case CB_GETITEMDATA:
402 dprintf_combo(stddeb,"ComboBox CB_GETITEMDATA wParam=%X !\n", wParam);
403 lphc = ComboGetStorageHeader(hwnd);
404 if (lphc == NULL) return 0;
405 return(SendMessage(lphc->hWndLBox, LB_GETITEMDATA, wParam, 0L));
406 break;
407 case CB_SETITEMDATA:
408 dprintf_combo(stddeb,"ComboBox CB_SETITEMDATA wParam=%04X lParam=%08lX!\n", wParam, lParam);
409 lphc = ComboGetStorageHeader(hwnd);
410 if (lphc == NULL) return 0;
411 return(SendMessage(lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam));
412 break;
413 case CB_LIMITTEXT:
414 dprintf_combo(stddeb,"ComboBox CB_LIMITTEXT !\n");
415 lphc = ComboGetStorageHeader(hwnd);
416 if (lphc == NULL) return 0;
417 /* if (lphc->hWndEdit != 0)
418 return(SendMessage(lphc->hWndEdit, EM_LIMITTEXT, wParam, 0L)); */
419 break;
421 default:
422 return DefWindowProc( hwnd, message, wParam, lParam );
424 return 0;
429 LPHEADCOMBO ComboGetStorageHeader(HWND hwnd)
431 WND *wndPtr;
432 LPHEADCOMBO lphc;
433 wndPtr = WIN_FindWndPtr(hwnd);
434 if (wndPtr == 0) {
435 fprintf(stderr,"Bad Window handle on ComboBox !\n");
436 return 0;
438 lphc = *((LPHEADCOMBO *)&wndPtr->wExtra[1]);
439 return lphc;
444 int CreateComboStruct(HWND hwnd)
446 WND *wndPtr;
447 LPHEADCOMBO lphc;
448 wndPtr = WIN_FindWndPtr(hwnd);
449 if (wndPtr == 0) {
450 fprintf(stderr,"Bad Window handle on ComboBox !\n");
451 return 0;
453 lphc = (LPHEADCOMBO)malloc(sizeof(HEADCOMBO));
454 *((LPHEADCOMBO *)&wndPtr->wExtra[1]) = lphc;
455 lphc->hWndEdit = 0;
456 lphc->hWndLBox = 0;
457 lphc->dwState = 0;
458 lphc->LastSel = -1;
459 return TRUE;
463 void ComboBoxStaticOwnerDraw(HWND hWnd, LPHEADCOMBO lphc)
465 HDC hDC;
466 HBRUSH hBrush;
467 short y;
468 char str[64];
469 LPSTR ptr = NULL;
470 HANDLE hTemp;
471 WND *wndPtr;
472 LPDRAWITEMSTRUCT lpdis;
473 dprintf_combo(stddeb,"ComboBoxStaticOwnerDraw(%04X, %p) !\n", hWnd, lphc);
474 y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
475 if (y != LB_ERR) {
476 SendMessage(lphc->hWndLBox, LB_GETTEXT, y, (LPARAM)str);
477 ptr = (LPSTR)SendMessage(lphc->hWndLBox, LB_GETITEMDATA, y, 0L);
479 hDC = GetDC(hWnd);
480 hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC,
481 MAKELONG(hWnd, CTLCOLOR_STATIC));
482 if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH);
483 wndPtr = WIN_FindWndPtr(hWnd);
484 if (wndPtr == NULL) return;
485 hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(DRAWITEMSTRUCT));
486 lpdis = (LPDRAWITEMSTRUCT) USER_HEAP_ADDR(hTemp);
487 if (lpdis == NULL) {
488 printf("ComboBox Ownerdraw // Error allocating DRAWITEMSTRUCT !\n");
489 ReleaseDC( hWnd, hDC );
490 return;
492 FillRect(hDC, &lphc->RectEdit, hBrush);
493 lpdis->hDC = hDC;
494 if (y != LB_ERR) lpdis->itemID = y - 1;
495 CopyRect(&lpdis->rcItem, &lphc->RectEdit);
496 lpdis->itemData = (DWORD)ptr;
497 lpdis->itemAction = ODA_DRAWENTIRE;
498 lpdis->CtlType = ODT_COMBOBOX;
499 lpdis->CtlID = wndPtr->wIDmenu;
500 SendMessage(GetParent(hWnd), WM_DRAWITEM, y, (LPARAM)lpdis);
501 USER_HEAP_FREE(hTemp);
502 ReleaseDC(hWnd, hDC);
506 /************************************************************************
507 * DlgDirSelectComboBox [USER.194]
509 BOOL DlgDirSelectComboBox(HWND hDlg, LPSTR lpStr, int nIDLBox)
511 fprintf(stdnimp,"DlgDirSelectComboBox(%04X, '%s', %d) \n",
512 hDlg, lpStr, nIDLBox);
513 return TRUE;
517 /************************************************************************
518 * DlgDirListComboBox [USER.195]
520 int DlgDirListComboBox(HWND hDlg, LPSTR lpPathSpec,
521 int nIDLBox, int nIDStat, WORD wType)
523 HWND hWnd;
524 LPHEADCOMBO lphc;
525 dprintf_combo(stddeb,"DlgDirListComboBox(%04X, '%s', %d, %d, %04X) \n",
526 hDlg, lpPathSpec, nIDLBox, nIDStat, wType);
527 hWnd = GetDlgItem(hDlg, nIDLBox);
528 lphc = ComboGetStorageHeader(hWnd);
529 if (lphc == NULL) return 0;
530 SendMessage(lphc->hWndLBox, LB_RESETCONTENT, 0, 0L);
531 return SendMessage(lphc->hWndLBox, LB_DIR, wType, (DWORD)lpPathSpec);