Do not free the old string in SysReAllocStringLen, reuse the old
[wine/wine-kai.git] / windows / dialog.c
blob893a211835fa7805308aac4c34cc65b7678a0e13
1 /*
2 * Dialog functions
4 * Copyright 1993, 1994, 1996 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <ctype.h>
25 #include <errno.h>
26 #include <limits.h>
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
31 #include "windef.h"
32 #include "winnls.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "windowsx.h"
37 #include "wine/winuser16.h"
38 #include "wine/winbase16.h"
39 #include "wownt32.h"
40 #include "wine/unicode.h"
41 #include "controls.h"
42 #include "heap.h"
43 #include "win.h"
44 #include "user.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(dialog);
50 /* Dialog control information */
51 typedef struct
53 DWORD style;
54 DWORD exStyle;
55 DWORD helpId;
56 INT16 x;
57 INT16 y;
58 INT16 cx;
59 INT16 cy;
60 UINT id;
61 LPCSTR className;
62 LPCSTR windowName;
63 LPCVOID data;
64 } DLG_CONTROL_INFO;
66 /* Dialog template */
67 typedef struct
69 DWORD style;
70 DWORD exStyle;
71 DWORD helpId;
72 UINT16 nbItems;
73 INT16 x;
74 INT16 y;
75 INT16 cx;
76 INT16 cy;
77 LPCSTR menuName;
78 LPCSTR className;
79 LPCSTR caption;
80 WORD pointSize;
81 WORD weight;
82 BOOL italic;
83 LPCSTR faceName;
84 BOOL dialogEx;
85 } DLG_TEMPLATE;
87 /* Radio button group */
88 typedef struct
90 UINT firstID;
91 UINT lastID;
92 UINT checkID;
93 } RADIOGROUP;
95 /* Dialog base units */
96 static WORD xBaseUnit = 0, yBaseUnit = 0;
99 /*********************************************************************
100 * dialog class descriptor
102 const struct builtin_class_descr DIALOG_builtin_class =
104 DIALOG_CLASS_ATOM, /* name */
105 CS_GLOBALCLASS | CS_SAVEBITS | CS_DBLCLKS, /* style */
106 DefDlgProcA, /* procA */
107 DefDlgProcW, /* procW */
108 DLGWINDOWEXTRA, /* extra */
109 IDC_ARROWA, /* cursor */
110 0 /* brush */
114 /***********************************************************************
115 * DIALOG_EnableOwner
117 * Helper function for modal dialogs to enable again the
118 * owner of the dialog box.
120 void DIALOG_EnableOwner( HWND hOwner )
122 /* Owner must be a top-level window */
123 if (hOwner)
124 hOwner = GetAncestor( hOwner, GA_ROOT );
125 if (!hOwner) return;
126 EnableWindow( hOwner, TRUE );
130 /***********************************************************************
131 * DIALOG_DisableOwner
133 * Helper function for modal dialogs to disable the
134 * owner of the dialog box. Returns TRUE if owner was enabled.
136 BOOL DIALOG_DisableOwner( HWND hOwner )
138 /* Owner must be a top-level window */
139 if (hOwner)
140 hOwner = GetAncestor( hOwner, GA_ROOT );
141 if (!hOwner) return FALSE;
142 if (IsWindowEnabled( hOwner ))
144 EnableWindow( hOwner, FALSE );
145 return TRUE;
147 else
148 return FALSE;
151 /***********************************************************************
152 * DIALOG_GetCharSizeFromDC
154 * Despite most of MSDN insisting that the horizontal base unit is
155 * tmAveCharWidth it isn't. Knowledge base article Q145994
156 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
157 * says that we should take the average of the 52 English upper and lower
158 * case characters.
160 static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
162 HFONT hFontPrev = 0;
163 char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
164 SIZE sz;
165 TEXTMETRICA tm;
167 pSize->cx = xBaseUnit;
168 pSize->cy = yBaseUnit;
170 if(!hDC) return FALSE;
172 if(hFont) hFontPrev = SelectFont(hDC, hFont);
173 if(!GetTextMetricsA(hDC, &tm)) return FALSE;
174 if(!GetTextExtentPointA(hDC, alphabet, 52, &sz)) return FALSE;
176 pSize->cy = tm.tmHeight;
177 pSize->cx = (sz.cx / 26 + 1) / 2;
179 if (hFontPrev) SelectFont(hDC, hFontPrev);
181 TRACE("dlg base units: %ld x %ld\n", pSize->cx, pSize->cy);
182 return TRUE;
185 /***********************************************************************
186 * DIALOG_GetCharSize
188 * A convenient variant of DIALOG_GetCharSizeFromDC.
190 static BOOL DIALOG_GetCharSize( HFONT hFont, SIZE * pSize )
192 HDC hDC = GetDC(0);
193 BOOL Success = DIALOG_GetCharSizeFromDC( hDC, hFont, pSize );
194 ReleaseDC(0, hDC);
195 return Success;
198 /***********************************************************************
199 * DIALOG_Init
201 * Initialisation of the dialog manager.
203 BOOL DIALOG_Init(void)
205 HDC hdc;
206 SIZE size;
208 /* Calculate the dialog base units */
210 if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL )))
212 ERR("Could not create Display DC\n");
213 return FALSE;
216 if (!DIALOG_GetCharSizeFromDC( hdc, 0, &size ))
218 DeleteDC( hdc );
219 ERR("Could not initialize base dialog units\n");
220 return FALSE;
223 DeleteDC( hdc );
224 xBaseUnit = size.cx;
225 yBaseUnit = size.cy;
227 TRACE("base units = %d,%d\n", xBaseUnit, yBaseUnit );
228 return TRUE;
232 /***********************************************************************
233 * DIALOG_GetControl16
235 * Return the class and text of the control pointed to by ptr,
236 * fill the header structure and return a pointer to the next control.
238 static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
240 static char buffer[10];
241 int int_id;
243 info->x = GET_WORD(p); p += sizeof(WORD);
244 info->y = GET_WORD(p); p += sizeof(WORD);
245 info->cx = GET_WORD(p); p += sizeof(WORD);
246 info->cy = GET_WORD(p); p += sizeof(WORD);
247 info->id = GET_WORD(p); p += sizeof(WORD);
248 info->style = GET_DWORD(p); p += sizeof(DWORD);
249 info->exStyle = 0;
251 if (*p & 0x80)
253 switch((BYTE)*p)
255 case 0x80: strcpy( buffer, "BUTTON" ); break;
256 case 0x81: strcpy( buffer, "EDIT" ); break;
257 case 0x82: strcpy( buffer, "STATIC" ); break;
258 case 0x83: strcpy( buffer, "LISTBOX" ); break;
259 case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
260 case 0x85: strcpy( buffer, "COMBOBOX" ); break;
261 default: buffer[0] = '\0'; break;
263 info->className = buffer;
264 p++;
266 else
268 info->className = p;
269 p += strlen(p) + 1;
272 int_id = ((BYTE)*p == 0xff);
273 if (int_id)
275 /* Integer id, not documented (?). Only works for SS_ICON controls */
276 info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
277 p += 3;
279 else
281 info->windowName = p;
282 p += strlen(p) + 1;
285 if (*p) info->data = p + 1;
286 else info->data = NULL;
288 p += *p + 1;
290 if(int_id)
291 TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %p\n",
292 info->className, LOWORD(info->windowName),
293 info->id, info->x, info->y, info->cx, info->cy,
294 info->style, info->data );
295 else
296 TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %p\n",
297 info->className, info->windowName,
298 info->id, info->x, info->y, info->cx, info->cy,
299 info->style, info->data );
301 return p;
305 /***********************************************************************
306 * DIALOG_GetControl32
308 * Return the class and text of the control pointed to by ptr,
309 * fill the header structure and return a pointer to the next control.
311 static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
312 BOOL dialogEx )
314 if (dialogEx)
316 info->helpId = GET_DWORD(p); p += 2;
317 info->exStyle = GET_DWORD(p); p += 2;
318 info->style = GET_DWORD(p); p += 2;
320 else
322 info->helpId = 0;
323 info->style = GET_DWORD(p); p += 2;
324 info->exStyle = GET_DWORD(p); p += 2;
326 info->x = GET_WORD(p); p++;
327 info->y = GET_WORD(p); p++;
328 info->cx = GET_WORD(p); p++;
329 info->cy = GET_WORD(p); p++;
331 if (dialogEx)
333 /* id is a DWORD for DIALOGEX */
334 info->id = GET_DWORD(p);
335 p += 2;
337 else
339 info->id = GET_WORD(p);
340 p++;
343 if (GET_WORD(p) == 0xffff)
345 static const WCHAR class_names[6][10] =
347 { 'B','u','t','t','o','n', }, /* 0x80 */
348 { 'E','d','i','t', }, /* 0x81 */
349 { 'S','t','a','t','i','c', }, /* 0x82 */
350 { 'L','i','s','t','B','o','x', }, /* 0x83 */
351 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
352 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
354 WORD id = GET_WORD(p+1);
355 if ((id >= 0x80) && (id <= 0x85))
356 info->className = (LPCSTR)class_names[id - 0x80];
357 else
359 info->className = NULL;
360 ERR("Unknown built-in class id %04x\n", id );
362 p += 2;
364 else
366 info->className = (LPCSTR)p;
367 p += strlenW( (LPCWSTR)p ) + 1;
370 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
372 info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1);
373 p += 2;
375 else
377 info->windowName = (LPCSTR)p;
378 p += strlenW( (LPCWSTR)p ) + 1;
381 TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
382 debugstr_w( (LPCWSTR)info->className ),
383 debugstr_w( (LPCWSTR)info->windowName ),
384 info->id, info->x, info->y, info->cx, info->cy,
385 info->style, info->exStyle, info->helpId );
387 if (GET_WORD(p))
389 if (TRACE_ON(dialog))
391 WORD i, count = GET_WORD(p) / sizeof(WORD);
392 TRACE(" BEGIN\n");
393 TRACE(" ");
394 for (i = 0; i < count; i++) DPRINTF( "%04x,", GET_WORD(p+i+1) );
395 DPRINTF("\n");
396 TRACE(" END\n" );
398 info->data = p + 1;
399 p += GET_WORD(p) / sizeof(WORD);
401 else info->data = NULL;
402 p++;
404 /* Next control is on dword boundary */
405 return (const WORD *)((((int)p) + 3) & ~3);
409 /***********************************************************************
410 * DIALOG_CreateControls16
412 * Create the control windows for a dialog.
414 static BOOL DIALOG_CreateControls16( HWND hwnd, LPCSTR template,
415 const DLG_TEMPLATE *dlgTemplate, HINSTANCE16 hInst )
417 DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd );
418 DLG_CONTROL_INFO info;
419 HWND hwndCtrl, hwndDefButton = 0;
420 INT items = dlgTemplate->nbItems;
422 TRACE(" BEGIN\n" );
423 while (items--)
425 HINSTANCE16 instance = hInst;
426 SEGPTR segptr;
428 template = DIALOG_GetControl16( template, &info );
429 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
430 !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT))
432 if (!dlgInfo->hDialogHeap)
434 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
435 if (!dlgInfo->hDialogHeap)
437 ERR("Insufficient memory to create heap for edit control\n" );
438 continue;
440 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
442 instance = dlgInfo->hDialogHeap;
445 segptr = MapLS( info.data );
446 hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
447 info.className, info.windowName,
448 info.style | WS_CHILD,
449 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
450 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
451 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
452 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
453 HWND_16(hwnd), (HMENU16)info.id,
454 instance, (LPVOID)segptr ));
455 UnMapLS( segptr );
457 if (!hwndCtrl) return FALSE;
459 /* Send initialisation messages to the control */
460 if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
461 (WPARAM)dlgInfo->hUserFont, 0 );
462 if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
464 /* If there's already a default push-button, set it back */
465 /* to normal and use this one instead. */
466 if (hwndDefButton)
467 SendMessageA( hwndDefButton, BM_SETSTYLE,
468 BS_PUSHBUTTON,FALSE );
469 hwndDefButton = hwndCtrl;
470 dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
473 TRACE(" END\n" );
474 return TRUE;
478 /***********************************************************************
479 * DIALOG_CreateControls32
481 * Create the control windows for a dialog.
483 static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template,
484 const DLG_TEMPLATE *dlgTemplate, HINSTANCE hInst )
486 DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd );
487 DLG_CONTROL_INFO info;
488 HWND hwndCtrl, hwndDefButton = 0;
489 INT items = dlgTemplate->nbItems;
491 TRACE(" BEGIN\n" );
492 while (items--)
494 template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
495 dlgTemplate->dialogEx );
496 /* Is this it? */
497 if (info.style & WS_BORDER)
499 info.style &= ~WS_BORDER;
500 info.exStyle |= WS_EX_CLIENTEDGE;
502 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY,
503 (LPCWSTR)info.className,
504 (LPCWSTR)info.windowName,
505 info.style | WS_CHILD,
506 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
507 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
508 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
509 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
510 hwnd, (HMENU)info.id,
511 hInst, (LPVOID)info.data );
512 if (!hwndCtrl) return FALSE;
514 /* Send initialisation messages to the control */
515 if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
516 (WPARAM)dlgInfo->hUserFont, 0 );
517 if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
519 /* If there's already a default push-button, set it back */
520 /* to normal and use this one instead. */
521 if (hwndDefButton)
522 SendMessageA( hwndDefButton, BM_SETSTYLE,
523 BS_PUSHBUTTON,FALSE );
524 hwndDefButton = hwndCtrl;
525 dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
528 TRACE(" END\n" );
529 return TRUE;
533 /***********************************************************************
534 * DIALOG_ParseTemplate16
536 * Fill a DLG_TEMPLATE structure from the dialog template, and return
537 * a pointer to the first control.
539 static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
541 result->style = GET_DWORD(p); p += sizeof(DWORD);
542 result->exStyle = 0;
543 result->nbItems = (unsigned char) *p++;
544 result->x = GET_WORD(p); p += sizeof(WORD);
545 result->y = GET_WORD(p); p += sizeof(WORD);
546 result->cx = GET_WORD(p); p += sizeof(WORD);
547 result->cy = GET_WORD(p); p += sizeof(WORD);
548 TRACE("DIALOG %d, %d, %d, %d\n",
549 result->x, result->y, result->cx, result->cy );
550 TRACE(" STYLE %08lx\n", result->style );
552 /* Get the menu name */
554 switch( (BYTE)*p )
556 case 0:
557 result->menuName = 0;
558 p++;
559 break;
560 case 0xff:
561 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
562 p += 3;
563 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
564 break;
565 default:
566 result->menuName = p;
567 TRACE(" MENU '%s'\n", p );
568 p += strlen(p) + 1;
569 break;
572 /* Get the class name */
574 if (*p)
576 result->className = p;
577 TRACE(" CLASS '%s'\n", result->className );
579 else result->className = DIALOG_CLASS_ATOM;
580 p += strlen(p) + 1;
582 /* Get the window caption */
584 result->caption = p;
585 p += strlen(p) + 1;
586 TRACE(" CAPTION '%s'\n", result->caption );
588 /* Get the font name */
590 if (result->style & DS_SETFONT)
592 result->pointSize = GET_WORD(p);
593 p += sizeof(WORD);
594 result->faceName = p;
595 p += strlen(p) + 1;
596 TRACE(" FONT %d,'%s'\n",
597 result->pointSize, result->faceName );
599 return p;
603 /***********************************************************************
604 * DIALOG_ParseTemplate32
606 * Fill a DLG_TEMPLATE structure from the dialog template, and return
607 * a pointer to the first control.
609 static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
611 const WORD *p = (const WORD *)template;
613 result->style = GET_DWORD(p); p += 2;
614 if (result->style == 0xffff0001) /* DIALOGEX resource */
616 result->dialogEx = TRUE;
617 result->helpId = GET_DWORD(p); p += 2;
618 result->exStyle = GET_DWORD(p); p += 2;
619 result->style = GET_DWORD(p); p += 2;
621 else
623 result->dialogEx = FALSE;
624 result->helpId = 0;
625 result->exStyle = GET_DWORD(p); p += 2;
627 result->nbItems = GET_WORD(p); p++;
628 result->x = GET_WORD(p); p++;
629 result->y = GET_WORD(p); p++;
630 result->cx = GET_WORD(p); p++;
631 result->cy = GET_WORD(p); p++;
632 TRACE("DIALOG%s %d, %d, %d, %d, %ld\n",
633 result->dialogEx ? "EX" : "", result->x, result->y,
634 result->cx, result->cy, result->helpId );
635 TRACE(" STYLE 0x%08lx\n", result->style );
636 TRACE(" EXSTYLE 0x%08lx\n", result->exStyle );
638 /* Get the menu name */
640 switch(GET_WORD(p))
642 case 0x0000:
643 result->menuName = NULL;
644 p++;
645 break;
646 case 0xffff:
647 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
648 p += 2;
649 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
650 break;
651 default:
652 result->menuName = (LPCSTR)p;
653 TRACE(" MENU %s\n", debugstr_w( (LPCWSTR)p ));
654 p += strlenW( (LPCWSTR)p ) + 1;
655 break;
658 /* Get the class name */
660 switch(GET_WORD(p))
662 case 0x0000:
663 result->className = DIALOG_CLASS_ATOM;
664 p++;
665 break;
666 case 0xffff:
667 result->className = (LPCSTR)(UINT)GET_WORD( p + 1 );
668 p += 2;
669 TRACE(" CLASS %04x\n", LOWORD(result->className) );
670 break;
671 default:
672 result->className = (LPCSTR)p;
673 TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR)p ));
674 p += strlenW( (LPCWSTR)p ) + 1;
675 break;
678 /* Get the window caption */
680 result->caption = (LPCSTR)p;
681 p += strlenW( (LPCWSTR)p ) + 1;
682 TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) );
684 /* Get the font name */
686 if (result->style & DS_SETFONT)
688 result->pointSize = GET_WORD(p);
689 p++;
690 if (result->dialogEx)
692 result->weight = GET_WORD(p); p++;
693 result->italic = LOBYTE(GET_WORD(p)); p++;
695 else
697 result->weight = FW_DONTCARE;
698 result->italic = FALSE;
700 result->faceName = (LPCSTR)p;
701 p += strlenW( (LPCWSTR)p ) + 1;
702 TRACE(" FONT %d, %s, %d, %s\n",
703 result->pointSize, debugstr_w( (LPCWSTR)result->faceName ),
704 result->weight, result->italic ? "TRUE" : "FALSE" );
707 /* First control is on dword boundary */
708 return (LPCSTR)((((int)p) + 3) & ~3);
712 /***********************************************************************
713 * DIALOG_CreateIndirect
714 * Creates a dialog box window
716 * modal = TRUE if we are called from a modal dialog box.
717 * (it's more compatible to do it here, as under Windows the owner
718 * is never disabled if the dialog fails because of an invalid template)
720 static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
721 HWND owner, DLGPROC dlgProc, LPARAM param,
722 WINDOWPROCTYPE procType, BOOL modal )
724 HWND hwnd;
725 RECT rect;
726 WND * wndPtr;
727 DLG_TEMPLATE template;
728 DIALOGINFO * dlgInfo;
729 BOOL ownerEnabled = TRUE;
730 BOOL win32Template = (procType != WIN_PROC_16);
731 BOOL res;
733 /* Parse dialog template */
735 if (!dlgTemplate) return 0;
736 if (win32Template)
737 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
738 else
739 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
741 /* Initialise dialog extra data */
743 if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return 0;
744 dlgInfo->hwndFocus = 0;
745 dlgInfo->hUserFont = 0;
746 dlgInfo->hMenu = 0;
747 dlgInfo->xBaseUnit = xBaseUnit;
748 dlgInfo->yBaseUnit = yBaseUnit;
749 dlgInfo->idResult = 0;
750 dlgInfo->flags = 0;
751 dlgInfo->hDialogHeap = 0;
753 /* Load menu */
755 if (template.menuName)
757 if (!win32Template) dlgInfo->hMenu = HMENU_32(LoadMenu16( HINSTANCE_16(hInst), template.menuName ));
758 else dlgInfo->hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName );
761 /* Create custom font if needed */
763 if (template.style & DS_SETFONT)
765 /* We convert the size to pixels and then make it -ve. This works
766 * for both +ve and -ve template.pointSize */
767 HDC dc;
768 int pixels;
769 dc = GetDC(0);
770 pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72);
771 ReleaseDC(0, dc);
772 if (win32Template)
773 dlgInfo->hUserFont = CreateFontW( -pixels, 0, 0, 0, template.weight,
774 template.italic, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
775 PROOF_QUALITY, FF_DONTCARE,
776 (LPCWSTR)template.faceName );
777 else
778 dlgInfo->hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
779 FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
780 PROOF_QUALITY, FF_DONTCARE, template.faceName );
781 if (dlgInfo->hUserFont)
783 SIZE charSize;
784 if (DIALOG_GetCharSize( dlgInfo->hUserFont, &charSize ))
786 dlgInfo->xBaseUnit = charSize.cx;
787 dlgInfo->yBaseUnit = charSize.cy;
790 TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit );
793 /* Create dialog main window */
795 rect.left = rect.top = 0;
796 rect.right = MulDiv(template.cx, dlgInfo->xBaseUnit, 4);
797 rect.bottom = MulDiv(template.cy, dlgInfo->yBaseUnit, 8);
798 if (template.style & DS_MODALFRAME)
799 template.exStyle |= WS_EX_DLGMODALFRAME;
800 AdjustWindowRectEx( &rect, template.style, (dlgInfo->hMenu != 0), template.exStyle );
801 rect.right -= rect.left;
802 rect.bottom -= rect.top;
804 if ((INT16)template.x == CW_USEDEFAULT16)
806 rect.left = rect.top = win32Template? CW_USEDEFAULT : CW_USEDEFAULT16;
808 else
810 if (template.style & DS_CENTER)
812 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
813 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
815 else
817 rect.left += MulDiv(template.x, dlgInfo->xBaseUnit, 4);
818 rect.top += MulDiv(template.y, dlgInfo->yBaseUnit, 8);
820 if ( !(template.style & WS_CHILD) )
822 INT16 dX, dY;
824 if( !(template.style & DS_ABSALIGN) )
825 ClientToScreen( owner, (POINT *)&rect );
827 /* try to fit it into the desktop */
829 if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME)
830 - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX;
831 if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME)
832 - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY;
833 if( rect.left < 0 ) rect.left = 0;
834 if( rect.top < 0 ) rect.top = 0;
838 if (modal)
840 ownerEnabled = DIALOG_DisableOwner( owner );
841 if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED;
844 if (!win32Template)
845 hwnd = WIN_Handle32( CreateWindowEx16(template.exStyle, template.className,
846 template.caption, template.style & ~WS_VISIBLE,
847 rect.left, rect.top, rect.right, rect.bottom,
848 HWND_16(owner), HMENU_16(dlgInfo->hMenu),
849 HINSTANCE_16(hInst), NULL ));
850 else
851 hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className,
852 (LPCWSTR)template.caption,
853 template.style & ~WS_VISIBLE,
854 rect.left, rect.top, rect.right, rect.bottom,
855 owner, dlgInfo->hMenu, hInst, NULL );
857 if (!hwnd)
859 if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
860 if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );
861 if (modal && (dlgInfo->flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
862 HeapFree( GetProcessHeap(), 0, dlgInfo );
863 return 0;
865 wndPtr = WIN_GetPtr( hwnd );
866 wndPtr->flags |= WIN_ISDIALOG;
867 WIN_ReleasePtr( wndPtr );
869 if (template.helpId) SetWindowContextHelpId( hwnd, template.helpId );
870 SetWindowLongW( hwnd, DWL_WINE_DIALOGINFO, (LONG)dlgInfo );
871 switch(procType)
873 case WIN_PROC_16: SetWindowLong16( HWND_16(hwnd), DWL_DLGPROC, (LONG)dlgProc ); break;
874 case WIN_PROC_32A: SetWindowLongA( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
875 case WIN_PROC_32W: SetWindowLongW( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
876 default: break;
879 if (dlgInfo->hUserFont)
880 SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
882 /* Create controls */
884 if (win32Template)
885 res = DIALOG_CreateControls32( hwnd, dlgTemplate, &template, hInst );
886 else
887 res = DIALOG_CreateControls16( hwnd, dlgTemplate, &template, HINSTANCE_16(hInst) );
889 if (res)
891 HWND hwndPreInitFocus;
893 /* Send initialisation messages and set focus */
895 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
897 hwndPreInitFocus = GetFocus();
898 if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
900 /* check where the focus is again,
901 * some controls status might have changed in WM_INITDIALOG */
902 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
903 if( dlgInfo->hwndFocus )
904 SetFocus( dlgInfo->hwndFocus );
906 else
908 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
909 but the focus has not changed, set the focus where we expect it. */
910 if ((GetFocus() == hwndPreInitFocus) &&
911 (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
913 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
914 if( dlgInfo->hwndFocus )
915 SetFocus( dlgInfo->hwndFocus );
919 if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
921 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
923 return hwnd;
925 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
926 if (modal && ownerEnabled) DIALOG_EnableOwner(owner);
927 return 0;
931 /***********************************************************************
932 * CreateDialog (USER.89)
934 HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
935 HWND16 owner, DLGPROC16 dlgProc )
937 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
941 /***********************************************************************
942 * CreateDialogParam (USER.241)
944 HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
945 HWND16 owner, DLGPROC16 dlgProc,
946 LPARAM param )
948 HWND16 hwnd = 0;
949 HRSRC16 hRsrc;
950 HGLOBAL16 hmem;
951 LPCVOID data;
953 TRACE("%04x,%s,%04x,%08lx,%ld\n",
954 hInst, debugstr_a(dlgTemplate), owner, (DWORD)dlgProc, param );
956 if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOGA ))) return 0;
957 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
958 if (!(data = LockResource16( hmem ))) hwnd = 0;
959 else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
960 dlgProc, param );
961 FreeResource16( hmem );
962 return hwnd;
965 /***********************************************************************
966 * CreateDialogParamA (USER32.@)
968 HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name,
969 HWND owner, DLGPROC dlgProc,
970 LPARAM param )
972 HRSRC hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
973 if (!hrsrc) return 0;
974 return CreateDialogIndirectParamA( hInst,
975 (LPVOID)LoadResource(hInst, hrsrc),
976 owner, dlgProc, param );
980 /***********************************************************************
981 * CreateDialogParamW (USER32.@)
983 HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name,
984 HWND owner, DLGPROC dlgProc,
985 LPARAM param )
987 HRSRC hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
988 if (!hrsrc) return 0;
989 return CreateDialogIndirectParamW( hInst,
990 (LPVOID)LoadResource(hInst, hrsrc),
991 owner, dlgProc, param );
995 /***********************************************************************
996 * CreateDialogIndirect (USER.219)
998 HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
999 HWND16 owner, DLGPROC16 dlgProc )
1001 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
1005 /***********************************************************************
1006 * CreateDialogIndirectParam (USER.242)
1008 HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst,
1009 LPCVOID dlgTemplate,
1010 HWND16 owner, DLGPROC16 dlgProc,
1011 LPARAM param )
1013 return HWND_16( DIALOG_CreateIndirect( HINSTANCE_32(hInst), dlgTemplate, WIN_Handle32(owner),
1014 (DLGPROC)dlgProc, param, WIN_PROC_16, FALSE ));
1018 /***********************************************************************
1019 * CreateDialogIndirectParamA (USER32.@)
1021 HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst,
1022 LPCDLGTEMPLATEA dlgTemplate,
1023 HWND owner, DLGPROC dlgProc,
1024 LPARAM param )
1026 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32A, FALSE );
1029 /***********************************************************************
1030 * CreateDialogIndirectParamAorW (USER32.@)
1032 HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst,
1033 LPCVOID dlgTemplate,
1034 HWND owner, DLGPROC dlgProc,
1035 LPARAM param )
1036 { FIXME("assume WIN_PROC_32W\n");
1037 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
1040 /***********************************************************************
1041 * CreateDialogIndirectParamW (USER32.@)
1043 HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst,
1044 LPCDLGTEMPLATEW dlgTemplate,
1045 HWND owner, DLGPROC dlgProc,
1046 LPARAM param )
1048 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
1052 /***********************************************************************
1053 * DIALOG_DoDialogBox
1055 static INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
1057 DIALOGINFO * dlgInfo;
1058 MSG msg;
1059 INT retval;
1060 HWND ownerMsg = GetAncestor( owner, GA_ROOT );
1062 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return -1;
1064 if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
1066 ShowWindow( hwnd, SW_SHOW );
1067 for (;;)
1069 if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG))
1071 if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
1073 /* No message present -> send ENTERIDLE and wait */
1074 SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd );
1075 if (!GetMessageW( &msg, 0, 0, 0 )) break;
1078 else if (!GetMessageW( &msg, 0, 0, 0 )) break;
1080 if (!IsWindow( hwnd )) return -1;
1081 if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))
1083 TranslateMessage( &msg );
1084 DispatchMessageW( &msg );
1086 if (dlgInfo->flags & DF_END) break;
1089 if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner );
1090 retval = dlgInfo->idResult;
1091 DestroyWindow( hwnd );
1092 return retval;
1096 /***********************************************************************
1097 * DialogBox (USER.87)
1099 INT16 WINAPI DialogBox16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
1100 HWND16 owner, DLGPROC16 dlgProc )
1102 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1106 /***********************************************************************
1107 * DialogBoxParam (USER.239)
1109 INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template,
1110 HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
1112 HWND hwnd = 0;
1113 HRSRC16 hRsrc;
1114 HGLOBAL16 hmem;
1115 LPCVOID data;
1116 int ret = -1;
1118 if (!(hRsrc = FindResource16( hInst, template, RT_DIALOGA ))) return 0;
1119 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
1120 if ((data = LockResource16( hmem )))
1122 HWND owner = WIN_Handle32(owner16);
1123 hwnd = DIALOG_CreateIndirect( HINSTANCE_32(hInst), data, owner,
1124 (DLGPROC)dlgProc, param, WIN_PROC_16, TRUE );
1125 if (hwnd) ret = DIALOG_DoDialogBox( hwnd, owner );
1126 GlobalUnlock16( hmem );
1128 FreeResource16( hmem );
1129 return ret;
1133 /***********************************************************************
1134 * DialogBoxParamA (USER32.@)
1136 INT_PTR WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
1137 HWND owner, DLGPROC dlgProc, LPARAM param )
1139 HWND hwnd;
1140 HRSRC hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
1141 if (!hrsrc) return 0;
1142 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1143 owner, dlgProc, param, WIN_PROC_32A, TRUE );
1144 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1145 return -1;
1149 /***********************************************************************
1150 * DialogBoxParamW (USER32.@)
1152 INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
1153 HWND owner, DLGPROC dlgProc, LPARAM param )
1155 HWND hwnd;
1156 HRSRC hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
1157 if (!hrsrc) return 0;
1158 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1159 owner, dlgProc, param, WIN_PROC_32W, TRUE );
1160 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1161 return -1;
1165 /***********************************************************************
1166 * DialogBoxIndirect (USER.218)
1168 INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1169 HWND16 owner, DLGPROC16 dlgProc )
1171 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1175 /***********************************************************************
1176 * DialogBoxIndirectParam (USER.240)
1178 INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1179 HWND16 owner16, DLGPROC16 dlgProc,
1180 LPARAM param )
1182 HWND hwnd, owner = WIN_Handle32( owner16 );
1183 LPCVOID ptr;
1185 if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
1186 hwnd = DIALOG_CreateIndirect( HINSTANCE_32(hInst), ptr, owner, (DLGPROC)dlgProc,
1187 param, WIN_PROC_16, TRUE );
1188 GlobalUnlock16( dlgTemplate );
1189 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1190 return -1;
1194 /***********************************************************************
1195 * DialogBoxIndirectParamA (USER32.@)
1197 INT_PTR WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCDLGTEMPLATEA template,
1198 HWND owner, DLGPROC dlgProc,
1199 LPARAM param )
1201 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1202 dlgProc, param, WIN_PROC_32A, TRUE );
1203 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1204 return -1;
1208 /***********************************************************************
1209 * DialogBoxIndirectParamW (USER32.@)
1211 INT_PTR WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW template,
1212 HWND owner, DLGPROC dlgProc,
1213 LPARAM param )
1215 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1216 dlgProc, param, WIN_PROC_32W, TRUE );
1217 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1218 return -1;
1221 /***********************************************************************
1222 * DialogBoxIndirectParamAorW (USER32.@)
1224 INT_PTR WINAPI DialogBoxIndirectParamAorW(HINSTANCE hInstance, LPCVOID template,
1225 HWND owner, DLGPROC dlgProc,
1226 LPARAM param, DWORD x )
1228 HWND hwnd;
1229 FIXME("%p %p %p %p 0x%08lx 0x%08lx\n",
1230 hInstance, template, owner, dlgProc, param, x);
1231 hwnd = DIALOG_CreateIndirect( hInstance, template, owner, dlgProc, param, WIN_PROC_32W, TRUE );
1232 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1233 return -1;
1236 /***********************************************************************
1237 * EndDialog (USER32.@)
1239 BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
1241 BOOL wasEnabled = TRUE;
1242 DIALOGINFO * dlgInfo;
1243 HWND owner;
1245 TRACE("%p %d\n", hwnd, retval );
1247 if (!(dlgInfo = DIALOG_get_info( hwnd )))
1249 ERR("got invalid window handle (%p); buggy app !?\n", hwnd);
1250 return FALSE;
1252 dlgInfo->idResult = retval;
1253 dlgInfo->flags |= DF_END;
1254 wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
1256 if (wasEnabled && (owner = GetWindow( hwnd, GW_OWNER )))
1257 DIALOG_EnableOwner( owner );
1259 /* Windows sets the focus to the dialog itself in EndDialog */
1261 if (IsChild(hwnd, GetFocus()))
1262 SetFocus( hwnd );
1264 /* Don't have to send a ShowWindow(SW_HIDE), just do
1265 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1267 SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
1268 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
1270 /* unblock dialog loop */
1271 PostMessageA(hwnd, WM_NULL, 0, 0);
1272 return TRUE;
1276 /***********************************************************************
1277 * DIALOG_IsAccelerator
1279 static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM wParam )
1281 HWND hwndControl = hwnd;
1282 HWND hwndNext;
1283 INT dlgCode;
1284 WCHAR buffer[128];
1288 DWORD style = GetWindowLongW( hwndControl, GWL_STYLE );
1289 if ((style & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE)
1291 dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
1292 if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
1293 GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) ))
1295 /* find the accelerator key */
1296 LPWSTR p = buffer - 2;
1300 p = strchrW( p + 2, '&' );
1302 while (p != NULL && p[1] == '&');
1304 /* and check if it's the one we're looking for */
1305 if (p != NULL && toupperW( p[1] ) == toupperW( wParam ) )
1307 if ((dlgCode & DLGC_STATIC) || (style & 0x0f) == BS_GROUPBOX )
1309 /* set focus to the control */
1310 SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, 1);
1311 /* and bump it on to next */
1312 SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
1314 else if (dlgCode & DLGC_BUTTON)
1316 /* send BM_CLICK message to the control */
1317 SendMessageA( hwndControl, BM_CLICK, 0, 0 );
1319 return TRUE;
1322 hwndNext = GetWindow( hwndControl, GW_CHILD );
1324 else hwndNext = 0;
1326 if (!hwndNext) hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1328 while (!hwndNext && hwndControl)
1330 hwndControl = GetParent( hwndControl );
1331 if (hwndControl == hwndDlg)
1333 if(hwnd==hwndDlg) /* prevent endless loop */
1335 hwndNext=hwnd;
1336 break;
1338 hwndNext = GetWindow( hwndDlg, GW_CHILD );
1340 else
1341 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1343 hwndControl = hwndNext;
1345 while (hwndControl && (hwndControl != hwnd));
1347 return FALSE;
1350 /***********************************************************************
1351 * DIALOG_FindMsgDestination
1353 * The messages that IsDialogMessage sends may not go to the dialog
1354 * calling IsDialogMessage if that dialog is a child, and it has the
1355 * DS_CONTROL style set.
1356 * We propagate up until we hit one that does not have DS_CONTROL, or
1357 * whose parent is not a dialog.
1359 * This is undocumented behaviour.
1361 static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
1363 while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL)
1365 WND *pParent;
1366 HWND hParent = GetParent(hwndDlg);
1367 if (!hParent) break;
1369 pParent = WIN_FindWndPtr(hParent);
1370 if (!pParent) break;
1372 if (!(pParent->flags & WIN_ISDIALOG))
1374 WIN_ReleaseWndPtr(pParent);
1375 break;
1377 WIN_ReleaseWndPtr(pParent);
1379 hwndDlg = hParent;
1382 return hwndDlg;
1385 /***********************************************************************
1386 * IsDialogMessageW (USER32.@)
1388 BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
1390 INT dlgCode = 0;
1392 if (CallMsgFilterW( msg, MSGF_DIALOGBOX )) return TRUE;
1394 hwndDlg = WIN_GetFullHandle( hwndDlg );
1395 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) return FALSE;
1397 hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
1399 switch(msg->message)
1401 case WM_KEYDOWN:
1402 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, msg->wParam, (LPARAM)msg );
1403 if (dlgCode & DLGC_WANTMESSAGE) break;
1405 switch(msg->wParam)
1407 case VK_TAB:
1408 if (!(dlgCode & DLGC_WANTTAB))
1410 SendMessageW( hwndDlg, WM_NEXTDLGCTL, (GetKeyState(VK_SHIFT) & 0x8000), 0 );
1411 return TRUE;
1413 break;
1415 case VK_RIGHT:
1416 case VK_DOWN:
1417 case VK_LEFT:
1418 case VK_UP:
1419 if (!(dlgCode & DLGC_WANTARROWS))
1421 BOOL fPrevious = (msg->wParam == VK_LEFT || msg->wParam == VK_UP);
1422 HWND hwndNext = GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious );
1423 SendMessageW( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndNext, 1 );
1424 return TRUE;
1426 break;
1428 case VK_CANCEL:
1429 case VK_ESCAPE:
1430 SendMessageW( hwndDlg, WM_COMMAND, IDCANCEL, (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
1431 return TRUE;
1433 case VK_EXECUTE:
1434 case VK_RETURN:
1436 DWORD dw = SendMessageW( hwndDlg, DM_GETDEFID, 0, 0 );
1437 if (HIWORD(dw) == DC_HASDEFID)
1439 SendMessageW( hwndDlg, WM_COMMAND, MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
1440 (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw)));
1442 else
1444 SendMessageW( hwndDlg, WM_COMMAND, IDOK, (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
1448 return TRUE;
1450 break;
1452 case WM_CHAR:
1453 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, msg->wParam, (LPARAM)msg );
1454 if (dlgCode & (DLGC_WANTCHARS|DLGC_WANTMESSAGE)) break;
1455 if (msg->wParam == '\t' && (dlgCode & DLGC_WANTTAB)) break;
1456 /* drop through */
1458 case WM_SYSCHAR:
1459 if (DIALOG_IsAccelerator( WIN_GetFullHandle(msg->hwnd), hwndDlg, msg->wParam ))
1461 /* don't translate or dispatch */
1462 return TRUE;
1464 break;
1467 TranslateMessage( msg );
1468 DispatchMessageW( msg );
1469 return TRUE;
1473 /***********************************************************************
1474 * GetDlgCtrlID (USER32.@)
1476 INT WINAPI GetDlgCtrlID( HWND hwnd )
1478 return GetWindowLongW( hwnd, GWL_ID );
1482 /***********************************************************************
1483 * GetDlgItem (USER32.@)
1485 HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
1487 int i;
1488 HWND *list = WIN_ListChildren( hwndDlg );
1489 HWND ret = 0;
1491 if (!list) return 0;
1493 for (i = 0; list[i]; i++) if (GetWindowLongW( list[i], GWL_ID ) == id) break;
1494 ret = list[i];
1495 HeapFree( GetProcessHeap(), 0, list );
1496 return ret;
1500 /*******************************************************************
1501 * SendDlgItemMessageA (USER32.@)
1503 LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg,
1504 WPARAM wParam, LPARAM lParam )
1506 HWND hwndCtrl = GetDlgItem( hwnd, id );
1507 if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam );
1508 else return 0;
1512 /*******************************************************************
1513 * SendDlgItemMessageW (USER32.@)
1515 LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg,
1516 WPARAM wParam, LPARAM lParam )
1518 HWND hwndCtrl = GetDlgItem( hwnd, id );
1519 if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam );
1520 else return 0;
1524 /*******************************************************************
1525 * SetDlgItemTextA (USER32.@)
1527 BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString )
1529 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1533 /*******************************************************************
1534 * SetDlgItemTextW (USER32.@)
1536 BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString )
1538 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1542 /***********************************************************************
1543 * GetDlgItemTextA (USER32.@)
1545 INT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, UINT len )
1547 return (INT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT,
1548 len, (LPARAM)str );
1552 /***********************************************************************
1553 * GetDlgItemTextW (USER32.@)
1555 INT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, UINT len )
1557 return (INT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT,
1558 len, (LPARAM)str );
1562 /*******************************************************************
1563 * SetDlgItemInt (USER32.@)
1565 BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value,
1566 BOOL fSigned )
1568 char str[20];
1570 if (fSigned) sprintf( str, "%d", (INT)value );
1571 else sprintf( str, "%u", value );
1572 SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
1573 return TRUE;
1577 /***********************************************************************
1578 * GetDlgItemInt (USER32.@)
1580 UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated,
1581 BOOL fSigned )
1583 char str[30];
1584 char * endptr;
1585 long result = 0;
1587 if (translated) *translated = FALSE;
1588 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
1589 return 0;
1590 if (fSigned)
1592 result = strtol( str, &endptr, 10 );
1593 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1594 return 0;
1595 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1596 return 0;
1598 else
1600 result = strtoul( str, &endptr, 10 );
1601 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1602 return 0;
1603 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1605 if (translated) *translated = TRUE;
1606 return (UINT)result;
1610 /***********************************************************************
1611 * CheckDlgButton (USER32.@)
1613 BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check )
1615 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
1616 return TRUE;
1620 /***********************************************************************
1621 * IsDlgButtonChecked (USER32.@)
1623 UINT WINAPI IsDlgButtonChecked( HWND hwnd, UINT id )
1625 return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
1629 /***********************************************************************
1630 * CheckRB
1632 * Callback function used to check/uncheck radio buttons that fall
1633 * within a specific range of IDs.
1635 static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam)
1637 LONG lChildID = GetWindowLongA(hwndChild, GWL_ID);
1638 RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam;
1640 if ((lChildID >= lpRadioGroup->firstID) &&
1641 (lChildID <= lpRadioGroup->lastID))
1643 if (lChildID == lpRadioGroup->checkID)
1645 SendMessageA(hwndChild, BM_SETCHECK, BST_CHECKED, 0);
1647 else
1649 SendMessageA(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0);
1653 return TRUE;
1657 /***********************************************************************
1658 * CheckRadioButton (USER32.@)
1660 BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
1661 UINT lastID, UINT checkID )
1663 RADIOGROUP radioGroup;
1665 /* perform bounds checking for a radio button group */
1666 radioGroup.firstID = min(min(firstID, lastID), checkID);
1667 radioGroup.lastID = max(max(firstID, lastID), checkID);
1668 radioGroup.checkID = checkID;
1670 return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB,
1671 (LPARAM)&radioGroup);
1675 /***********************************************************************
1676 * GetDialogBaseUnits (USER.243)
1677 * GetDialogBaseUnits (USER32.@)
1679 DWORD WINAPI GetDialogBaseUnits(void)
1681 return MAKELONG( xBaseUnit, yBaseUnit );
1685 /***********************************************************************
1686 * MapDialogRect (USER32.@)
1688 BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
1690 DIALOGINFO * dlgInfo;
1691 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return FALSE;
1692 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1693 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1694 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1695 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
1696 return TRUE;
1700 /***********************************************************************
1701 * GetNextDlgGroupItem (USER32.@)
1703 HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1705 HWND hwnd, retvalue;
1707 hwndDlg = WIN_GetFullHandle( hwndDlg );
1708 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1710 if(hwndCtrl)
1712 /* if the hwndCtrl is the child of the control in the hwndDlg,
1713 * then the hwndDlg has to be the parent of the hwndCtrl */
1714 if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg)
1715 hwndDlg = GetParent(hwndCtrl);
1718 if (hwndCtrl)
1720 /* Make sure hwndCtrl is a top-level child */
1721 HWND parent = GetParent( hwndCtrl );
1722 while (parent && parent != hwndDlg) parent = GetParent(parent);
1723 if (parent != hwndDlg) return 0;
1725 else
1727 /* No ctrl specified -> start from the beginning */
1728 if (!(hwndCtrl = GetWindow( hwndDlg, GW_CHILD ))) return 0;
1729 if (fPrevious) hwndCtrl = GetWindow( hwndCtrl, GW_HWNDLAST );
1732 retvalue = hwndCtrl;
1733 hwnd = GetWindow( hwndCtrl, GW_HWNDNEXT );
1734 while (1)
1736 if (!hwnd || (GetWindowLongW( hwnd, GWL_STYLE ) & WS_GROUP))
1738 /* Wrap-around to the beginning of the group */
1739 HWND tmp;
1741 hwnd = GetWindow( hwndDlg, GW_CHILD );
1742 for (tmp = hwnd; tmp; tmp = GetWindow( tmp, GW_HWNDNEXT ) )
1744 if (GetWindowLongW( tmp, GWL_STYLE ) & WS_GROUP) hwnd = tmp;
1745 if (tmp == hwndCtrl) break;
1748 if (hwnd == hwndCtrl) break;
1749 if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE)
1751 retvalue = hwnd;
1752 if (!fPrevious) break;
1754 hwnd = GetWindow( hwnd, GW_HWNDNEXT );
1756 return retvalue;
1760 /***********************************************************************
1761 * DIALOG_GetNextTabItem
1763 * Helper for GetNextDlgTabItem
1765 static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1767 LONG dsStyle;
1768 LONG exStyle;
1769 UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
1770 HWND retWnd = 0;
1771 HWND hChildFirst = 0;
1773 if(!hwndCtrl)
1775 hChildFirst = GetWindow(hwndDlg,GW_CHILD);
1776 if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
1778 else if (IsChild( hwndMain, hwndCtrl ))
1780 hChildFirst = GetWindow(hwndCtrl,wndSearch);
1781 if(!hChildFirst)
1783 if(GetParent(hwndCtrl) != hwndMain)
1784 hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
1785 else
1787 if(fPrevious)
1788 hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST);
1789 else
1790 hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST);
1795 while(hChildFirst)
1797 BOOL bCtrl = FALSE;
1798 while(hChildFirst)
1800 dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
1801 exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
1802 if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1804 bCtrl=TRUE;
1805 break;
1807 else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1808 break;
1809 hChildFirst = GetWindow(hChildFirst,wndSearch);
1811 if(hChildFirst)
1813 if(bCtrl)
1814 retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,NULL,fPrevious );
1815 else
1816 retWnd = hChildFirst;
1818 if(retWnd) break;
1819 hChildFirst = GetWindow(hChildFirst,wndSearch);
1821 if(!retWnd && hwndCtrl)
1823 HWND hParent = GetParent(hwndCtrl);
1824 while(hParent)
1826 if(hParent == hwndMain) break;
1827 retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
1828 if(retWnd) break;
1829 hParent = GetParent(hParent);
1831 if(!retWnd)
1832 retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,NULL,fPrevious );
1834 return retWnd;
1837 /***********************************************************************
1838 * GetNextDlgTabItem (USER32.@)
1840 HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
1841 BOOL fPrevious )
1843 hwndDlg = WIN_GetFullHandle( hwndDlg );
1844 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1845 return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious);
1848 /**********************************************************************
1849 * DIALOG_DlgDirSelect
1851 * Helper function for DlgDirSelect*
1853 static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
1854 INT id, BOOL unicode, BOOL combo )
1856 char *buffer, *ptr;
1857 INT item, size;
1858 BOOL ret;
1859 HWND listbox = GetDlgItem( hwnd, id );
1861 TRACE("%p '%s' %d\n", hwnd, str, id );
1862 if (!listbox) return FALSE;
1864 item = SendMessageA(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 );
1865 if (item == LB_ERR) return FALSE;
1866 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN : LB_GETTEXTLEN, 0, 0 );
1867 if (size == LB_ERR) return FALSE;
1869 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size+1 ))) return FALSE;
1871 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, item, (LPARAM)buffer );
1873 if ((ret = (buffer[0] == '['))) /* drive or directory */
1875 if (buffer[1] == '-') /* drive */
1877 buffer[3] = ':';
1878 buffer[4] = 0;
1879 ptr = buffer + 2;
1881 else
1883 buffer[strlen(buffer)-1] = '\\';
1884 ptr = buffer + 1;
1887 else ptr = buffer;
1889 if (unicode)
1891 if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, ptr, -1, (LPWSTR)str, len ))
1892 ((LPWSTR)str)[len-1] = 0;
1894 else lstrcpynA( str, ptr, len );
1895 HeapFree( GetProcessHeap(), 0, buffer );
1896 TRACE("Returning %d '%s'\n", ret, str );
1897 return ret;
1901 /**********************************************************************
1902 * DIALOG_DlgDirList
1904 * Helper function for DlgDirList*
1906 static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
1907 INT idStatic, UINT attrib, BOOL combo )
1909 HWND hwnd;
1910 LPSTR orig_spec = spec;
1912 #define SENDMSG(msg,wparam,lparam) \
1913 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
1914 : SendMessageA( hwnd, msg, wparam, lparam ))
1916 TRACE("%p '%s' %d %d %04x\n",
1917 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
1919 /* If the path exists and is a directory, chdir to it */
1920 if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = "*.*";
1921 else
1923 char *p, *p2;
1924 p = spec;
1925 if ((p2 = strrchr( p, '\\' ))) p = p2;
1926 if ((p2 = strrchr( p, '/' ))) p = p2;
1927 if (p != spec)
1929 char sep = *p;
1930 *p = 0;
1931 if (!SetCurrentDirectoryA( spec ))
1933 *p = sep; /* Restore the original spec */
1934 return FALSE;
1936 spec = p + 1;
1940 TRACE( "mask=%s\n", spec );
1942 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
1944 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
1945 if (attrib & DDL_DIRECTORY)
1947 if (!(attrib & DDL_EXCLUSIVE))
1949 if (SENDMSG( combo ? CB_DIR : LB_DIR,
1950 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
1951 (LPARAM)spec ) == LB_ERR)
1952 return FALSE;
1954 if (SENDMSG( combo ? CB_DIR : LB_DIR,
1955 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
1956 (LPARAM)"*.*" ) == LB_ERR)
1957 return FALSE;
1959 else
1961 if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
1962 (LPARAM)spec ) == LB_ERR)
1963 return FALSE;
1967 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
1969 char temp[MAX_PATH];
1970 GetCurrentDirectoryA( sizeof(temp), temp );
1971 CharLowerA( temp );
1972 /* Can't use PostMessage() here, because the string is on the stack */
1973 SetDlgItemTextA( hDlg, idStatic, temp );
1976 if (orig_spec && (spec != orig_spec))
1978 /* Update the original file spec */
1979 char *p = spec;
1980 while ((*orig_spec++ = *p++));
1983 return TRUE;
1984 #undef SENDMSG
1988 /**********************************************************************
1989 * DIALOG_DlgDirListW
1991 * Helper function for DlgDirList*W
1993 static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
1994 INT idStatic, UINT attrib, BOOL combo )
1996 if (spec)
1998 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
1999 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
2000 attrib, combo );
2001 MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff );
2002 HeapFree( GetProcessHeap(), 0, specA );
2003 return ret;
2005 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
2009 /**********************************************************************
2010 * DlgDirSelectExA (USER32.@)
2012 BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id )
2014 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE );
2018 /**********************************************************************
2019 * DlgDirSelectExW (USER32.@)
2021 BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id )
2023 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, FALSE );
2027 /**********************************************************************
2028 * DlgDirSelectComboBoxExA (USER32.@)
2030 BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len,
2031 INT id )
2033 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, TRUE );
2037 /**********************************************************************
2038 * DlgDirSelectComboBoxExW (USER32.@)
2040 BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len,
2041 INT id)
2043 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE );
2047 /**********************************************************************
2048 * DlgDirListA (USER32.@)
2050 INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
2051 INT idStatic, UINT attrib )
2053 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2057 /**********************************************************************
2058 * DlgDirListW (USER32.@)
2060 INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2061 INT idStatic, UINT attrib )
2063 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2067 /**********************************************************************
2068 * DlgDirListComboBoxA (USER32.@)
2070 INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox,
2071 INT idStatic, UINT attrib )
2073 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2077 /**********************************************************************
2078 * DlgDirListComboBoxW (USER32.@)
2080 INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox,
2081 INT idStatic, UINT attrib )
2083 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );