4 * Copyright 1993, 1994, 1996 Alexandre Julliard
17 #include "wine/winuser16.h"
18 #include "wine/winbase16.h"
19 #include "wine/unicode.h"
29 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(dialog);
34 /* Dialog control information */
71 /* Radio button group */
79 /* Dialog base units */
80 static WORD xBaseUnit = 0, yBaseUnit = 0;
83 /***********************************************************************
86 * Helper function for modal dialogs to enable again the
87 * owner of the dialog box.
89 void DIALOG_EnableOwner( HWND hOwner, BOOL ownerWasEnabled)
91 /* Owner must be a top-level window */
93 hOwner = WIN_GetTopParent( hOwner );
96 EnableWindow( hOwner, TRUE );
100 /***********************************************************************
101 * DIALOG_DisableOwner
103 * Helper function for modal dialogs to disable the
104 * owner of the dialog box. Returns TRUE if owner was enabled.
106 BOOL DIALOG_DisableOwner( HWND hOwner )
108 /* Owner must be a top-level window */
110 hOwner = WIN_GetTopParent( hOwner );
111 if (!hOwner) return FALSE;
112 if (IsWindowEnabled( hOwner ))
114 EnableWindow( hOwner, FALSE );
121 /***********************************************************************
122 * DIALOG_GetCharSizeFromDC
125 * Calculates the *true* average size of English characters in the
126 * specified font as oppposed to the one returned by GetTextMetrics.
128 * Latest: the X font driver will now compute a proper average width
129 * so this code can be removed
131 static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
133 BOOL Success = FALSE;
135 pSize->cx = xBaseUnit;
136 pSize->cy = yBaseUnit;
139 /* select the font */
141 memset(&tm,0,sizeof(tm));
142 if (hFont) hFontPrev = SelectFont(hDC,hFont);
143 if (GetTextMetricsA(hDC,&tm))
145 pSize->cx = tm.tmAveCharWidth;
146 pSize->cy = tm.tmHeight;
148 /* if variable width font */
149 if (tm.tmPitchAndFamily & TMPF_FIXED_PITCH)
152 const char* szAvgChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
154 /* Calculate a true average as opposed to the one returned
155 * by tmAveCharWidth. This works better when dealing with
156 * proportional spaced fonts and (more important) that's
157 * how Microsoft's dialog creation code calculates the size
160 if (GetTextExtentPointA(hDC,szAvgChars,sizeof(szAvgChars),&total))
163 pSize->cx = ((2*total.cx/sizeof(szAvgChars)) + 1)/2;
171 /* Use the text metrics */
172 TRACE("Using tm: %ldx%ld (dlg: %dx%d) (%s)\n", tm.tmAveCharWidth, tm.tmHeight, pSize->cx, pSize->cy,
173 tm.tmPitchAndFamily & TMPF_FIXED_PITCH ? "variable" : "fixed");
174 pSize->cx = tm.tmAveCharWidth;
175 pSize->cy = tm.tmHeight;
177 /* select the original font */
178 if (hFontPrev) SelectFont(hDC,hFontPrev);
183 /***********************************************************************
186 * A convenient variant of DIALOG_GetCharSizeFromDC.
188 static BOOL DIALOG_GetCharSize( HFONT hFont, SIZE * pSize )
191 BOOL Success = DIALOG_GetCharSizeFromDC( hDC, hFont, pSize );
196 /***********************************************************************
199 * Initialisation of the dialog manager.
201 BOOL DIALOG_Init(void)
206 /* Calculate the dialog base units */
208 if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL ))) return FALSE;
209 if (!DIALOG_GetCharSizeFromDC( hdc, 0, &size )) return FALSE;
214 TRACE("base units = %d,%d\n", xBaseUnit, yBaseUnit );
219 /***********************************************************************
220 * DIALOG_GetControl16
222 * Return the class and text of the control pointed to by ptr,
223 * fill the header structure and return a pointer to the next control.
225 static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
227 static char buffer[10];
230 info->x = GET_WORD(p); p += sizeof(WORD);
231 info->y = GET_WORD(p); p += sizeof(WORD);
232 info->cx = GET_WORD(p); p += sizeof(WORD);
233 info->cy = GET_WORD(p); p += sizeof(WORD);
234 info->id = GET_WORD(p); p += sizeof(WORD);
235 info->style = GET_DWORD(p); p += sizeof(DWORD);
242 case 0x80: strcpy( buffer, "BUTTON" ); break;
243 case 0x81: strcpy( buffer, "EDIT" ); break;
244 case 0x82: strcpy( buffer, "STATIC" ); break;
245 case 0x83: strcpy( buffer, "LISTBOX" ); break;
246 case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
247 case 0x85: strcpy( buffer, "COMBOBOX" ); break;
248 default: buffer[0] = '\0'; break;
250 info->className = buffer;
259 int_id = ((BYTE)*p == 0xff);
262 /* Integer id, not documented (?). Only works for SS_ICON controls */
263 info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
268 info->windowName = p;
274 /* Additional CTLDATA available for this control. */
275 info->data = SEGPTR_ALLOC(*p);
276 memcpy( info->data, p + 1, *p );
278 else info->data = NULL;
283 TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %08lx\n",
284 info->className, LOWORD(info->windowName),
285 info->id, info->x, info->y, info->cx, info->cy,
286 info->style, (DWORD)SEGPTR_GET(info->data) );
288 TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %08lx\n",
289 info->className, info->windowName,
290 info->id, info->x, info->y, info->cx, info->cy,
291 info->style, (DWORD)SEGPTR_GET(info->data) );
297 /***********************************************************************
298 * DIALOG_GetControl32
300 * Return the class and text of the control pointed to by ptr,
301 * fill the header structure and return a pointer to the next control.
303 static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
308 info->helpId = GET_DWORD(p); p += 2;
309 info->exStyle = GET_DWORD(p); p += 2;
310 info->style = GET_DWORD(p); p += 2;
315 info->style = GET_DWORD(p); p += 2;
316 info->exStyle = GET_DWORD(p); p += 2;
318 info->x = GET_WORD(p); p++;
319 info->y = GET_WORD(p); p++;
320 info->cx = GET_WORD(p); p++;
321 info->cy = GET_WORD(p); p++;
325 /* id is a DWORD for DIALOGEX */
326 info->id = GET_DWORD(p);
331 info->id = GET_WORD(p);
335 if (GET_WORD(p) == 0xffff)
337 static const WCHAR class_names[6][10] =
339 { 'B','u','t','t','o','n', }, /* 0x80 */
340 { 'E','d','i','t', }, /* 0x81 */
341 { 'S','t','a','t','i','c', }, /* 0x82 */
342 { 'L','i','s','t','B','o','x', }, /* 0x83 */
343 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
344 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
346 WORD id = GET_WORD(p+1);
347 if ((id >= 0x80) && (id <= 0x85))
348 info->className = (LPCSTR)class_names[id - 0x80];
351 info->className = NULL;
352 ERR("Unknown built-in class id %04x\n", id );
358 info->className = (LPCSTR)p;
359 p += strlenW( (LPCWSTR)p ) + 1;
362 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
364 info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1);
369 info->windowName = (LPCSTR)p;
370 p += strlenW( (LPCWSTR)p ) + 1;
373 TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
374 debugstr_w( (LPCWSTR)info->className ),
375 debugres_w( (LPCWSTR)info->windowName ),
376 info->id, info->x, info->y, info->cx, info->cy,
377 info->style, info->exStyle, info->helpId );
381 if (TRACE_ON(dialog))
383 WORD i, count = GET_WORD(p) / sizeof(WORD);
386 for (i = 0; i < count; i++) DPRINTF( "%04x,", GET_WORD(p+i+1) );
390 info->data = (LPVOID)(p + 1);
391 p += GET_WORD(p) / sizeof(WORD);
393 else info->data = NULL;
396 /* Next control is on dword boundary */
397 return (const WORD *)((((int)p) + 3) & ~3);
401 /***********************************************************************
402 * DIALOG_CreateControls
404 * Create the control windows for a dialog.
406 static BOOL DIALOG_CreateControls( WND *pWnd, LPCSTR template,
407 const DLG_TEMPLATE *dlgTemplate,
408 HINSTANCE hInst, BOOL win32 )
410 DIALOGINFO *dlgInfo = (DIALOGINFO *)pWnd->wExtra;
411 DLG_CONTROL_INFO info;
412 HWND hwndCtrl, hwndDefButton = 0;
413 INT items = dlgTemplate->nbItems;
420 HINSTANCE16 instance;
421 template = DIALOG_GetControl16( template, &info );
422 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
423 ((pWnd->dwStyle & DS_LOCALEDIT) != DS_LOCALEDIT))
425 if (!dlgInfo->hDialogHeap)
427 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
428 if (!dlgInfo->hDialogHeap)
430 ERR("Insufficient memory to create heap for edit control\n" );
433 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
435 instance = dlgInfo->hDialogHeap;
437 else instance = (HINSTANCE16)hInst;
439 hwndCtrl = CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
440 info.className, info.windowName,
441 info.style | WS_CHILD,
442 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
443 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
444 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
445 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
446 pWnd->hwndSelf, (HMENU16)info.id,
447 instance, (LPVOID)SEGPTR_GET(info.data) );
449 if (info.data) SEGPTR_FREE(info.data);
453 template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
454 dlgTemplate->dialogEx );
455 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY,
456 (LPCWSTR)info.className,
457 (LPCWSTR)info.windowName,
458 info.style | WS_CHILD,
459 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
460 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
461 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
462 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
463 pWnd->hwndSelf, (HMENU)info.id,
466 if (!hwndCtrl) return FALSE;
468 /* Send initialisation messages to the control */
469 if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
470 (WPARAM)dlgInfo->hUserFont, 0 );
471 if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
473 /* If there's already a default push-button, set it back */
474 /* to normal and use this one instead. */
476 SendMessageA( hwndDefButton, BM_SETSTYLE,
477 BS_PUSHBUTTON,FALSE );
478 hwndDefButton = hwndCtrl;
479 dlgInfo->idResult = GetWindowWord( hwndCtrl, GWW_ID );
487 /***********************************************************************
488 * DIALOG_ParseTemplate16
490 * Fill a DLG_TEMPLATE structure from the dialog template, and return
491 * a pointer to the first control.
493 static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
495 result->style = GET_DWORD(p); p += sizeof(DWORD);
497 result->nbItems = (unsigned char) *p++;
498 result->x = GET_WORD(p); p += sizeof(WORD);
499 result->y = GET_WORD(p); p += sizeof(WORD);
500 result->cx = GET_WORD(p); p += sizeof(WORD);
501 result->cy = GET_WORD(p); p += sizeof(WORD);
502 TRACE("DIALOG %d, %d, %d, %d\n",
503 result->x, result->y, result->cx, result->cy );
504 TRACE(" STYLE %08lx\n", result->style );
506 /* Get the menu name */
511 result->menuName = 0;
515 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
517 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
520 result->menuName = p;
521 TRACE(" MENU '%s'\n", p );
526 /* Get the class name */
530 result->className = p;
531 TRACE(" CLASS '%s'\n", result->className );
533 else result->className = DIALOG_CLASS_ATOM;
536 /* Get the window caption */
540 TRACE(" CAPTION '%s'\n", result->caption );
542 /* Get the font name */
544 if (result->style & DS_SETFONT)
546 result->pointSize = GET_WORD(p);
548 result->faceName = p;
550 TRACE(" FONT %d,'%s'\n",
551 result->pointSize, result->faceName );
557 /***********************************************************************
558 * DIALOG_ParseTemplate32
560 * Fill a DLG_TEMPLATE structure from the dialog template, and return
561 * a pointer to the first control.
563 static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
565 const WORD *p = (const WORD *)template;
567 result->style = GET_DWORD(p); p += 2;
568 if (result->style == 0xffff0001) /* DIALOGEX resource */
570 result->dialogEx = TRUE;
571 result->helpId = GET_DWORD(p); p += 2;
572 result->exStyle = GET_DWORD(p); p += 2;
573 result->style = GET_DWORD(p); p += 2;
577 result->dialogEx = FALSE;
579 result->exStyle = GET_DWORD(p); p += 2;
581 result->nbItems = GET_WORD(p); p++;
582 result->x = GET_WORD(p); p++;
583 result->y = GET_WORD(p); p++;
584 result->cx = GET_WORD(p); p++;
585 result->cy = GET_WORD(p); p++;
586 TRACE("DIALOG%s %d, %d, %d, %d, %ld\n",
587 result->dialogEx ? "EX" : "", result->x, result->y,
588 result->cx, result->cy, result->helpId );
589 TRACE(" STYLE 0x%08lx\n", result->style );
590 TRACE(" EXSTYLE 0x%08lx\n", result->exStyle );
592 /* Get the menu name */
597 result->menuName = NULL;
601 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
603 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
606 result->menuName = (LPCSTR)p;
607 TRACE(" MENU %s\n", debugstr_w( (LPCWSTR)p ));
608 p += strlenW( (LPCWSTR)p ) + 1;
612 /* Get the class name */
617 result->className = DIALOG_CLASS_ATOM;
621 result->className = (LPCSTR)(UINT)GET_WORD( p + 1 );
623 TRACE(" CLASS %04x\n", LOWORD(result->className) );
626 result->className = (LPCSTR)p;
627 TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR)p ));
628 p += strlenW( (LPCWSTR)p ) + 1;
632 /* Get the window caption */
634 result->caption = (LPCSTR)p;
635 p += strlenW( (LPCWSTR)p ) + 1;
636 TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) );
638 /* Get the font name */
640 if (result->style & DS_SETFONT)
642 result->pointSize = GET_WORD(p);
644 if (result->dialogEx)
646 result->weight = GET_WORD(p); p++;
647 result->italic = LOBYTE(GET_WORD(p)); p++;
651 result->weight = FW_DONTCARE;
652 result->italic = FALSE;
654 result->faceName = (LPCSTR)p;
655 p += strlenW( (LPCWSTR)p ) + 1;
656 TRACE(" FONT %d, %s, %d, %s\n",
657 result->pointSize, debugstr_w( (LPCWSTR)result->faceName ),
658 result->weight, result->italic ? "TRUE" : "FALSE" );
661 /* First control is on dword boundary */
662 return (LPCSTR)((((int)p) + 3) & ~3);
666 /***********************************************************************
667 * DIALOG_CreateIndirect
668 * Creates a dialog box window
670 * modal = TRUE if we are called from a modal dialog box.
671 * (it's more compatible to do it here, as under Windows the owner
672 * is never disabled if the dialog fails because of an invalid template)
674 static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
675 BOOL win32Template, HWND owner,
676 DLGPROC16 dlgProc, LPARAM param,
677 WINDOWPROCTYPE procType, BOOL modal )
684 DLG_TEMPLATE template;
685 DIALOGINFO * dlgInfo;
686 WORD xUnit = xBaseUnit;
687 WORD yUnit = yBaseUnit;
688 BOOL ownerEnabled = TRUE;
690 /* Parse dialog template */
692 if (!dlgTemplate) return 0;
694 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
696 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
700 if (template.menuName)
704 LPSTR str = SEGPTR_STRDUP( template.menuName );
705 hMenu = LoadMenu16( hInst, SEGPTR_GET(str) );
708 else hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName );
711 /* Create custom font if needed */
713 if (template.style & DS_SETFONT)
715 /* The font height must be negative as it is a point size */
716 /* and must be converted to pixels first */
717 /* (see CreateFont() documentation in the Windows SDK). */
719 int pixels = template.pointSize * GetDeviceCaps(dc , LOGPIXELSY)/72;
723 hFont = CreateFontW( -pixels, 0, 0, 0, template.weight,
724 template.italic, FALSE, FALSE,
725 DEFAULT_CHARSET, 0, 0,
726 PROOF_QUALITY, FF_DONTCARE,
727 (LPCWSTR)template.faceName );
729 hFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
731 DEFAULT_CHARSET, 0, 0,
732 PROOF_QUALITY, FF_DONTCARE,
737 if (DIALOG_GetCharSize(hFont,&charSize))
743 TRACE("units = %d,%d\n", xUnit, yUnit );
746 /* Create dialog main window */
748 rect.left = rect.top = 0;
749 rect.right = MulDiv(template.cx, xUnit, 4);
750 rect.bottom = MulDiv(template.cy, yUnit, 8);
751 if (template.style & DS_MODALFRAME)
752 template.exStyle |= WS_EX_DLGMODALFRAME;
753 AdjustWindowRectEx( &rect, template.style,
754 hMenu ? TRUE : FALSE , template.exStyle );
755 rect.right -= rect.left;
756 rect.bottom -= rect.top;
758 if ((INT16)template.x == CW_USEDEFAULT16)
760 rect.left = rect.top = win32Template? CW_USEDEFAULT : CW_USEDEFAULT16;
764 if (template.style & DS_CENTER)
766 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
767 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
771 rect.left += MulDiv(template.x, xUnit, 4);
772 rect.top += MulDiv(template.y, yUnit, 8);
774 if ( !(template.style & WS_CHILD) )
778 if( !(template.style & DS_ABSALIGN) )
779 ClientToScreen( owner, (POINT *)&rect );
781 /* try to fit it into the desktop */
783 if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME)
784 - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX;
785 if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME)
786 - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY;
787 if( rect.left < 0 ) rect.left = 0;
788 if( rect.top < 0 ) rect.top = 0;
793 ownerEnabled = DIALOG_DisableOwner( owner );
796 hwnd = CreateWindowEx16(template.exStyle, template.className,
797 template.caption, template.style & ~WS_VISIBLE,
798 rect.left, rect.top, rect.right, rect.bottom,
799 owner, hMenu, hInst, NULL );
801 hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className,
802 (LPCWSTR)template.caption,
803 template.style & ~WS_VISIBLE,
804 rect.left, rect.top, rect.right, rect.bottom,
805 owner, hMenu, hInst, NULL );
809 if (hFont) DeleteObject( hFont );
810 if (hMenu) DestroyMenu( hMenu );
812 DIALOG_EnableOwner(owner, ownerEnabled);
815 wndPtr = WIN_FindWndPtr( hwnd );
816 wndPtr->flags |= WIN_ISDIALOG;
817 wndPtr->helpContext = template.helpId;
819 /* Initialise dialog extra data */
821 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
822 WINPROC_SetProc( &dlgInfo->dlgProc, (WNDPROC16)dlgProc, procType, WIN_PROC_WINDOW );
823 dlgInfo->hUserFont = hFont;
824 dlgInfo->hMenu = hMenu;
825 dlgInfo->xBaseUnit = xUnit;
826 dlgInfo->yBaseUnit = yUnit;
827 dlgInfo->msgResult = 0;
828 dlgInfo->idResult = 0;
829 dlgInfo->flags = ownerEnabled ? DF_OWNERENABLED: 0;
830 dlgInfo->hDialogHeap = 0;
832 if (dlgInfo->hUserFont)
833 SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
835 /* Create controls */
837 if (DIALOG_CreateControls( wndPtr, dlgTemplate, &template,
838 hInst, win32Template ))
840 HWND hwndPreInitFocus;
842 /* Send initialisation messages and set focus */
844 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
846 hwndPreInitFocus = GetFocus();
847 if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
849 /* check where the focus is again, some controls status might have changed in
851 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
852 SetFocus( dlgInfo->hwndFocus );
856 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
857 but the focus has not changed, set the focus where we expect it. */
858 if ( (wndPtr->dwStyle & WS_VISIBLE) && ( GetFocus() == hwndPreInitFocus ) )
860 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
861 SetFocus( dlgInfo->hwndFocus );
865 if (template.style & WS_VISIBLE && !(wndPtr->dwStyle & WS_VISIBLE))
867 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
869 WIN_ReleaseWndPtr(wndPtr);
872 WIN_ReleaseWndPtr(wndPtr);
873 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
875 DIALOG_EnableOwner(owner, ownerEnabled);
880 /***********************************************************************
881 * CreateDialog16 (USER.89)
883 HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
884 HWND16 owner, DLGPROC16 dlgProc )
886 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
890 /***********************************************************************
891 * CreateDialogParam16 (USER.241)
893 HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
894 HWND16 owner, DLGPROC16 dlgProc,
902 TRACE("%04x,%08lx,%04x,%08lx,%ld\n",
903 hInst, (DWORD)dlgTemplate, owner, (DWORD)dlgProc, param );
905 if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOG16 ))) return 0;
906 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
907 if (!(data = LockResource16( hmem ))) hwnd = 0;
908 else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
910 FreeResource16( hmem );
914 /***********************************************************************
915 * CreateDialogParamA (USER32.73)
917 HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name,
918 HWND owner, DLGPROC dlgProc,
921 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
922 if (!hrsrc) return 0;
923 return CreateDialogIndirectParamA( hInst,
924 (LPVOID)LoadResource(hInst, hrsrc),
925 owner, dlgProc, param );
929 /***********************************************************************
930 * CreateDialogParamW (USER32.74)
932 HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name,
933 HWND owner, DLGPROC dlgProc,
936 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
937 if (!hrsrc) return 0;
938 return CreateDialogIndirectParamW( hInst,
939 (LPVOID)LoadResource(hInst, hrsrc),
940 owner, dlgProc, param );
944 /***********************************************************************
945 * CreateDialogIndirect16 (USER.219)
947 HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
948 HWND16 owner, DLGPROC16 dlgProc )
950 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
954 /***********************************************************************
955 * CreateDialogIndirectParam16 (USER.242)
957 HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst,
959 HWND16 owner, DLGPROC16 dlgProc,
962 return DIALOG_CreateIndirect( hInst, dlgTemplate, FALSE, owner,
963 dlgProc, param, WIN_PROC_16, FALSE );
967 /***********************************************************************
968 * CreateDialogIndirectParamA (USER32.69)
970 HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst,
972 HWND owner, DLGPROC dlgProc,
975 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
976 (DLGPROC16)dlgProc, param, WIN_PROC_32A, FALSE );
979 /***********************************************************************
980 * CreateDialogIndirectParamAorW (USER32.71)
982 HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst,
984 HWND owner, DLGPROC dlgProc,
986 { FIXME("assume WIN_PROC_32W\n");
987 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
988 (DLGPROC16)dlgProc, param, WIN_PROC_32W, FALSE );
991 /***********************************************************************
992 * CreateDialogIndirectParamW (USER32.72)
994 HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst,
996 HWND owner, DLGPROC dlgProc,
999 return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
1000 (DLGPROC16)dlgProc, param, WIN_PROC_32W, FALSE );
1004 /***********************************************************************
1005 * DIALOG_DoDialogBox
1007 static INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
1010 DIALOGINFO * dlgInfo;
1013 HWND ownerMsg = WIN_GetTopParent( owner );
1015 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
1016 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
1018 if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
1020 ShowWindow( hwnd, SW_SHOW );
1021 while (MSG_InternalGetMessage(QMSG_WIN32A, &msg, hwnd, ownerMsg, MSGF_DIALOGBOX,
1022 PM_REMOVE, !(wndPtr->dwStyle & DS_NOIDLEMSG), NULL ))
1024 if (!IsDialogMessageA( hwnd, &msg))
1026 TranslateMessage( &msg );
1027 DispatchMessageA( &msg );
1029 if (dlgInfo->flags & DF_END) break;
1032 DIALOG_EnableOwner( owner, (dlgInfo->flags & DF_OWNERENABLED) );
1033 retval = dlgInfo->idResult;
1034 WIN_ReleaseWndPtr(wndPtr);
1035 DestroyWindow( hwnd );
1040 /***********************************************************************
1041 * DialogBox16 (USER.87)
1043 INT16 WINAPI DialogBox16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
1044 HWND16 owner, DLGPROC16 dlgProc )
1046 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1050 /***********************************************************************
1051 * DialogBoxParam16 (USER.239)
1053 INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, SEGPTR template,
1054 HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
1062 if (!(hRsrc = FindResource16( hInst, template, RT_DIALOG16 ))) return 0;
1063 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
1064 if (!(data = LockResource16( hmem ))) hwnd = 0;
1065 else hwnd = DIALOG_CreateIndirect( hInst, data, FALSE, owner,
1066 dlgProc, param, WIN_PROC_16, TRUE );
1068 ret =(INT16)DIALOG_DoDialogBox( hwnd, owner );
1069 if (data) GlobalUnlock16( hmem );
1070 FreeResource16( hmem );
1075 /***********************************************************************
1076 * DialogBoxParamA (USER32.139)
1078 INT WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
1079 HWND owner, DLGPROC dlgProc, LPARAM param )
1082 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
1083 if (!hrsrc) return 0;
1084 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1086 (DLGPROC16) dlgProc, param, WIN_PROC_32A, TRUE );
1087 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1092 /***********************************************************************
1093 * DialogBoxParamW (USER32.140)
1095 INT WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
1096 HWND owner, DLGPROC dlgProc, LPARAM param )
1099 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
1100 if (!hrsrc) return 0;
1101 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1103 (DLGPROC16)dlgProc, param, WIN_PROC_32W, TRUE );
1104 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1109 /***********************************************************************
1110 * DialogBoxIndirect16 (USER.218)
1112 INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1113 HWND16 owner, DLGPROC16 dlgProc )
1115 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1119 /***********************************************************************
1120 * DialogBoxIndirectParam16 (USER.240)
1122 INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1123 HWND16 owner, DLGPROC16 dlgProc,
1129 if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
1130 hwnd = DIALOG_CreateIndirect( hInst, ptr, FALSE, owner,
1131 dlgProc, param, WIN_PROC_16, TRUE );
1132 GlobalUnlock16( dlgTemplate );
1133 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1138 /***********************************************************************
1139 * DialogBoxIndirectParamA (USER32.136)
1141 INT WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCVOID template,
1142 HWND owner, DLGPROC dlgProc,
1145 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, TRUE, owner,
1146 (DLGPROC16) dlgProc, param, WIN_PROC_32A, TRUE );
1147 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1152 /***********************************************************************
1153 * DialogBoxIndirectParamW (USER32.138)
1155 INT WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCVOID template,
1156 HWND owner, DLGPROC dlgProc,
1159 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, TRUE, owner,
1160 (DLGPROC16)dlgProc, param, WIN_PROC_32W, TRUE );
1161 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1165 /***********************************************************************
1166 * DialogBoxIndirectParamAorW (USER32.138)
1168 INT WINAPI DialogBoxIndirectParamAorW(HINSTANCE hInstance, LPCVOID template,
1169 HWND owner, DLGPROC dlgProc,
1170 LPARAM param, DWORD x )
1173 FIXME("0x%08x %p 0x%08x %p 0x%08lx 0x%08lx\n",
1174 hInstance, template, owner, dlgProc, param, x);
1175 hwnd = DIALOG_CreateIndirect( hInstance, template, TRUE, owner,
1176 (DLGPROC16)dlgProc, param, WIN_PROC_32W, TRUE );
1177 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1181 /***********************************************************************
1182 * EndDialog16 (USER.88)
1184 BOOL16 WINAPI EndDialog16( HWND16 hwnd, INT16 retval )
1186 return EndDialog( hwnd, retval );
1190 /***********************************************************************
1191 * EndDialog (USER32.173)
1193 BOOL WINAPI EndDialog( HWND hwnd, INT retval )
1195 WND * wndPtr = WIN_FindWndPtr( hwnd );
1196 BOOL wasEnabled = TRUE;
1197 DIALOGINFO * dlgInfo;
1199 TRACE("%04x %d\n", hwnd, retval );
1203 ERR("got invalid window handle (%04x); buggy app !?\n", hwnd);
1207 if ((dlgInfo = (DIALOGINFO *)wndPtr->wExtra))
1209 dlgInfo->idResult = retval;
1210 dlgInfo->flags |= DF_END;
1211 wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
1215 DIALOG_EnableOwner( wndPtr->owner->hwndSelf, wasEnabled );
1217 /* Windows sets the focus to the dialog itself in EndDialog */
1219 if (IsChild(hwnd, GetFocus()))
1220 SetFocus(wndPtr->hwndSelf);
1222 /* Don't have to send a ShowWindow(SW_HIDE), just do
1223 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1225 SetWindowPos(hwnd, (HWND)0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
1226 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
1228 WIN_ReleaseWndPtr(wndPtr);
1234 /***********************************************************************
1235 * DIALOG_IsAccelerator
1237 static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey )
1239 HWND hwndControl = hwnd;
1242 BOOL RetVal = FALSE;
1247 wndPtr = WIN_FindWndPtr( hwndControl );
1248 if ( (wndPtr != NULL) &&
1249 ((wndPtr->dwStyle & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE) )
1251 dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
1252 if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
1253 (wndPtr->text!=NULL))
1255 /* find the accelerator key */
1256 LPWSTR p = wndPtr->text - 2;
1259 p = strchrW( p + 2, '&' );
1261 while (p != NULL && p[1] == '&');
1263 /* and check if it's the one we're looking for */
1264 /* FIXME: convert vKey to unicode */
1265 if (p != NULL && toupperW( p[1] ) == (WCHAR)toupper( vKey ) )
1267 if ((dlgCode & DLGC_STATIC) ||
1268 (wndPtr->dwStyle & 0x0f) == BS_GROUPBOX )
1270 /* set focus to the control */
1271 SendMessageA( hwndDlg, WM_NEXTDLGCTL,
1273 /* and bump it on to next */
1274 SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
1276 else if (dlgCode & DLGC_BUTTON)
1278 /* send BM_CLICK message to the control */
1279 SendMessageA( hwndControl, BM_CLICK, 0, 0 );
1283 WIN_ReleaseWndPtr(wndPtr);
1287 hwndNext = GetWindow( hwndControl, GW_CHILD );
1293 WIN_ReleaseWndPtr(wndPtr);
1296 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1298 while (!hwndNext && hwndControl)
1300 hwndControl = GetParent( hwndControl );
1301 if (hwndControl == hwndDlg)
1303 if(hwnd==hwndDlg){ /* prevent endless loop */
1307 hwndNext = GetWindow( hwndDlg, GW_CHILD );
1311 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1314 hwndControl = hwndNext;
1316 while (hwndControl && (hwndControl != hwnd));
1321 /***********************************************************************
1322 * DIALOG_FindMsgDestination
1324 * The messages that IsDialogMessage send may not go to the dialog
1325 * calling IsDialogMessage if that dialog is a child, and it has the
1326 * DS_CONTROL style set.
1327 * We propagate up until we hit a that does not have DS_CONTROL, or
1328 * whose parent is not a dialog.
1330 * This is undocumented behaviour.
1332 static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
1334 while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL)
1337 HWND hParent = GetParent(hwndDlg);
1338 if (!hParent) break;
1340 pParent = WIN_FindWndPtr(hParent);
1341 if (!pParent) break;
1343 if (!(pParent->flags & WIN_ISDIALOG))
1345 WIN_ReleaseWndPtr(pParent);
1348 WIN_ReleaseWndPtr(pParent);
1356 /***********************************************************************
1357 * DIALOG_IsDialogMessage
1359 static BOOL DIALOG_IsDialogMessage( HWND hwnd, HWND hwndDlg,
1360 UINT message, WPARAM wParam,
1361 LPARAM lParam, BOOL *translate,
1362 BOOL *dispatch, INT dlgCode )
1364 *translate = *dispatch = FALSE;
1366 if (message == WM_PAINT)
1368 /* Apparently, we have to handle this one as well */
1373 /* Only the key messages get special processing */
1374 if ((message != WM_KEYDOWN) &&
1375 (message != WM_SYSCHAR) &&
1376 (message != WM_CHAR))
1379 if (dlgCode & DLGC_WANTMESSAGE)
1381 *translate = *dispatch = TRUE;
1385 hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
1393 if (!(dlgCode & DLGC_WANTTAB))
1395 SendMessageA( hwndDlg, WM_NEXTDLGCTL,
1396 (GetKeyState(VK_SHIFT) & 0x8000), 0 );
1405 if (!(dlgCode & DLGC_WANTARROWS))
1407 BOOL fPrevious = (wParam == VK_LEFT || wParam == VK_UP);
1409 GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious );
1410 SendMessageA( hwndDlg, WM_NEXTDLGCTL, hwndNext, 1 );
1416 SendMessageA( hwndDlg, WM_COMMAND, IDCANCEL,
1417 (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
1422 DWORD dw = SendMessage16( hwndDlg, DM_GETDEFID, 0, 0 );
1423 if (HIWORD(dw) == DC_HASDEFID)
1425 SendMessageA( hwndDlg, WM_COMMAND,
1426 MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
1427 (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw)));
1431 SendMessageA( hwndDlg, WM_COMMAND, IDOK,
1432 (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
1439 break; /* case WM_KEYDOWN */
1442 if (dlgCode & DLGC_WANTCHARS) break;
1446 if (DIALOG_IsAccelerator( hwnd, hwndDlg, wParam ))
1448 /* don't translate or dispatch */
1454 /* If we get here, the message has not been treated specially */
1455 /* and can be sent to its destination window. */
1461 /***********************************************************************
1462 * IsDialogMessage16 (USER.90)
1464 BOOL16 WINAPI WIN16_IsDialogMessage16( HWND16 hwndDlg, SEGPTR msg16 )
1466 LPMSG16 msg = PTR_SEG_TO_LIN(msg16);
1467 BOOL ret, translate, dispatch;
1470 if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
1473 if ((msg->message == WM_KEYDOWN) ||
1474 (msg->message == WM_SYSCHAR) ||
1475 (msg->message == WM_CHAR))
1477 dlgCode = SendMessage16( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg16);
1479 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1480 msg->wParam, msg->lParam,
1481 &translate, &dispatch, dlgCode );
1482 if (translate) TranslateMessage16( msg );
1483 if (dispatch) DispatchMessage16( msg );
1488 BOOL16 WINAPI IsDialogMessage16( HWND16 hwndDlg, LPMSG16 msg )
1490 LPMSG16 msg16 = SEGPTR_NEW(MSG16);
1494 ret = WIN16_IsDialogMessage16( hwndDlg, SEGPTR_GET(msg16) );
1499 /***********************************************************************
1500 * IsDialogMessageA (USER32.342)
1502 BOOL WINAPI IsDialogMessageA( HWND hwndDlg, LPMSG msg )
1504 BOOL ret, translate, dispatch;
1507 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
1510 if ((msg->message == WM_KEYDOWN) ||
1511 (msg->message == WM_SYSCHAR) ||
1512 (msg->message == WM_CHAR))
1514 dlgCode = SendMessageA( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1516 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1517 msg->wParam, msg->lParam,
1518 &translate, &dispatch, dlgCode );
1519 if (translate) TranslateMessage( msg );
1520 if (dispatch) DispatchMessageA( msg );
1525 /***********************************************************************
1526 * IsDialogMessageW (USER32.343)
1528 BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
1530 BOOL ret, translate, dispatch;
1533 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
1536 if ((msg->message == WM_KEYDOWN) ||
1537 (msg->message == WM_SYSCHAR) ||
1538 (msg->message == WM_CHAR))
1540 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1542 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1543 msg->wParam, msg->lParam,
1544 &translate, &dispatch, dlgCode );
1545 if (translate) TranslateMessage( msg );
1546 if (dispatch) DispatchMessageW( msg );
1551 /***********************************************************************
1552 * GetDlgCtrlID16 (USER.277)
1554 INT16 WINAPI GetDlgCtrlID16( HWND16 hwnd )
1556 WND *wndPtr = WIN_FindWndPtr(hwnd);
1559 if (!wndPtr) return 0;
1561 retvalue = wndPtr->wIDmenu;
1562 WIN_ReleaseWndPtr(wndPtr);
1567 /***********************************************************************
1568 * GetDlgCtrlID (USER32.234)
1570 INT WINAPI GetDlgCtrlID( HWND hwnd )
1573 WND *wndPtr = WIN_FindWndPtr(hwnd);
1574 if (!wndPtr) return 0;
1575 retvalue = wndPtr->wIDmenu;
1576 WIN_ReleaseWndPtr(wndPtr);
1581 /***********************************************************************
1582 * GetDlgItem16 (USER.91)
1584 HWND16 WINAPI GetDlgItem16( HWND16 hwndDlg, INT16 id )
1588 if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
1589 for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
1590 if (pWnd->wIDmenu == (UINT16)id)
1592 HWND16 retvalue = pWnd->hwndSelf;
1593 WIN_ReleaseWndPtr(pWnd);
1600 /***********************************************************************
1601 * GetDlgItem (USER32.235)
1603 HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
1607 if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0;
1608 for (WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd;WIN_UpdateWndPtr(&pWnd,pWnd->next))
1609 if (pWnd->wIDmenu == (UINT16)id)
1611 HWND retvalue = pWnd->hwndSelf;
1612 WIN_ReleaseWndPtr(pWnd);
1619 /*******************************************************************
1620 * SendDlgItemMessage16 (USER.101)
1622 LRESULT WINAPI SendDlgItemMessage16( HWND16 hwnd, INT16 id, UINT16 msg,
1623 WPARAM16 wParam, LPARAM lParam )
1625 HWND16 hwndCtrl = GetDlgItem16( hwnd, id );
1626 if (hwndCtrl) return SendMessage16( hwndCtrl, msg, wParam, lParam );
1631 /*******************************************************************
1632 * SendDlgItemMessageA (USER32.452)
1634 LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg,
1635 WPARAM wParam, LPARAM lParam )
1637 HWND hwndCtrl = GetDlgItem( hwnd, id );
1638 if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam );
1643 /*******************************************************************
1644 * SendDlgItemMessageW (USER32.453)
1646 LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg,
1647 WPARAM wParam, LPARAM lParam )
1649 HWND hwndCtrl = GetDlgItem( hwnd, id );
1650 if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam );
1655 /*******************************************************************
1656 * SetDlgItemText16 (USER.92)
1658 void WINAPI SetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR lpString )
1660 SendDlgItemMessage16( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1664 /*******************************************************************
1665 * SetDlgItemTextA (USER32.478)
1667 BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString )
1669 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1673 /*******************************************************************
1674 * SetDlgItemTextW (USER32.479)
1676 BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString )
1678 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1682 /***********************************************************************
1683 * GetDlgItemText16 (USER.93)
1685 INT16 WINAPI GetDlgItemText16( HWND16 hwnd, INT16 id, SEGPTR str, UINT16 len )
1687 return (INT16)SendDlgItemMessage16( hwnd, id, WM_GETTEXT,
1692 /***********************************************************************
1693 * GetDlgItemTextA (USER32.237)
1695 INT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, UINT len )
1697 return (INT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT,
1702 /***********************************************************************
1703 * GetDlgItemTextW (USER32.238)
1705 INT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, UINT len )
1707 return (INT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT,
1712 /*******************************************************************
1713 * SetDlgItemInt16 (USER.94)
1715 void WINAPI SetDlgItemInt16( HWND16 hwnd, INT16 id, UINT16 value, BOOL16 fSigned )
1717 SetDlgItemInt( hwnd, (UINT)(UINT16)id, value, fSigned );
1721 /*******************************************************************
1722 * SetDlgItemInt (USER32.477)
1724 BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value,
1729 if (fSigned) sprintf( str, "%d", (INT)value );
1730 else sprintf( str, "%u", value );
1731 SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
1736 /***********************************************************************
1737 * GetDlgItemInt16 (USER.95)
1739 UINT16 WINAPI GetDlgItemInt16( HWND16 hwnd, INT16 id, BOOL16 *translated,
1745 if (translated) *translated = FALSE;
1746 result = GetDlgItemInt( hwnd, (UINT)(UINT16)id, &ok, fSigned );
1750 if (((INT)result < -32767) || ((INT)result > 32767)) return 0;
1754 if (result > 65535) return 0;
1756 if (translated) *translated = TRUE;
1757 return (UINT16)result;
1761 /***********************************************************************
1762 * GetDlgItemInt (USER32.236)
1764 UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated,
1771 if (translated) *translated = FALSE;
1772 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
1776 result = strtol( str, &endptr, 10 );
1777 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1779 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1784 result = strtoul( str, &endptr, 10 );
1785 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1787 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1789 if (translated) *translated = TRUE;
1790 return (UINT)result;
1794 /***********************************************************************
1795 * CheckDlgButton16 (USER.97)
1797 BOOL16 WINAPI CheckDlgButton16( HWND16 hwnd, INT16 id, UINT16 check )
1799 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
1804 /***********************************************************************
1805 * CheckDlgButton (USER32.45)
1807 BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check )
1809 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
1814 /***********************************************************************
1815 * IsDlgButtonChecked16 (USER.98)
1817 UINT16 WINAPI IsDlgButtonChecked16( HWND16 hwnd, UINT16 id )
1819 return (UINT16)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
1823 /***********************************************************************
1824 * IsDlgButtonChecked (USER32.344)
1826 UINT WINAPI IsDlgButtonChecked( HWND hwnd, UINT id )
1828 return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
1832 /***********************************************************************
1833 * CheckRadioButton16 (USER.96)
1835 BOOL16 WINAPI CheckRadioButton16( HWND16 hwndDlg, UINT16 firstID,
1836 UINT16 lastID, UINT16 checkID )
1838 return CheckRadioButton( hwndDlg, firstID, lastID, checkID );
1842 /***********************************************************************
1845 * Callback function used to check/uncheck radio buttons that fall
1846 * within a specific range of IDs.
1848 static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam)
1850 LONG lChildID = GetWindowLongA(hwndChild, GWL_ID);
1851 RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam;
1853 if ((lChildID >= lpRadioGroup->firstID) &&
1854 (lChildID <= lpRadioGroup->lastID))
1856 if (lChildID == lpRadioGroup->checkID)
1858 SendMessageA(hwndChild, BM_SETCHECK, BST_CHECKED, 0);
1862 SendMessageA(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0);
1870 /***********************************************************************
1871 * CheckRadioButton (USER32.48)
1873 BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
1874 UINT lastID, UINT checkID )
1876 RADIOGROUP radioGroup;
1878 /* perform bounds checking for a radio button group */
1879 radioGroup.firstID = min(min(firstID, lastID), checkID);
1880 radioGroup.lastID = max(max(firstID, lastID), checkID);
1881 radioGroup.checkID = checkID;
1883 return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB,
1884 (LPARAM)&radioGroup);
1888 /***********************************************************************
1889 * GetDialogBaseUnits (USER.243) (USER32.233)
1891 DWORD WINAPI GetDialogBaseUnits(void)
1893 return MAKELONG( xBaseUnit, yBaseUnit );
1897 /***********************************************************************
1898 * MapDialogRect16 (USER.103)
1900 void WINAPI MapDialogRect16( HWND16 hwnd, LPRECT16 rect )
1902 DIALOGINFO * dlgInfo;
1903 WND * wndPtr = WIN_FindWndPtr( hwnd );
1904 if (!wndPtr) return;
1905 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
1906 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1907 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1908 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1909 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
1910 WIN_ReleaseWndPtr(wndPtr);
1914 /***********************************************************************
1915 * MapDialogRect (USER32.382)
1917 BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
1919 DIALOGINFO * dlgInfo;
1920 WND * wndPtr = WIN_FindWndPtr( hwnd );
1921 if (!wndPtr) return FALSE;
1922 dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
1923 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1924 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1925 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1926 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
1927 WIN_ReleaseWndPtr(wndPtr);
1932 /***********************************************************************
1933 * GetNextDlgGroupItem16 (USER.227)
1935 HWND16 WINAPI GetNextDlgGroupItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
1938 return (HWND16)GetNextDlgGroupItem( hwndDlg, hwndCtrl, fPrevious );
1942 /***********************************************************************
1943 * GetNextDlgGroupItem (USER32.275)
1945 HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl,
1956 /* if the hwndCtrl is the child of the control in the hwndDlg then the hwndDlg has to be the parent of the hwndCtrl */
1957 if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg)
1958 hwndDlg = GetParent(hwndCtrl);
1961 if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0;
1964 if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl )))
1969 /* Make sure hwndCtrl is a top-level child */
1970 while ((pWndCtrl->dwStyle & WS_CHILD) && (pWndCtrl->parent != pWndDlg))
1971 WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->parent);
1972 if (pWndCtrl->parent != pWndDlg)
1980 /* No ctrl specified -> start from the beginning */
1981 if (!(pWndCtrl = WIN_LockWndPtr(pWndDlg->child)))
1987 while (pWndCtrl->next) WIN_UpdateWndPtr(&pWndCtrl,pWndCtrl->next);
1990 pWndLast = WIN_LockWndPtr(pWndCtrl);
1991 pWnd = WIN_LockWndPtr(pWndCtrl->next);
1995 if (!pWnd || (pWnd->dwStyle & WS_GROUP))
1997 /* Wrap-around to the beginning of the group */
2000 WIN_UpdateWndPtr( &pWnd, pWndDlg->child );
2001 for ( pWndTemp = WIN_LockWndPtr( pWnd );
2003 WIN_UpdateWndPtr( &pWndTemp, pWndTemp->next) )
2005 if (pWndTemp->dwStyle & WS_GROUP) WIN_UpdateWndPtr( &pWnd, pWndTemp );
2006 if (pWndTemp == pWndCtrl) break;
2008 WIN_ReleaseWndPtr( pWndTemp );
2010 if (pWnd == pWndCtrl) break;
2011 if ((pWnd->dwStyle & WS_VISIBLE) && !(pWnd->dwStyle & WS_DISABLED))
2013 WIN_UpdateWndPtr(&pWndLast,pWnd);
2014 if (!fPrevious) break;
2016 WIN_UpdateWndPtr(&pWnd,pWnd->next);
2018 retvalue = pWndLast->hwndSelf;
2020 WIN_ReleaseWndPtr(pWndLast);
2021 WIN_ReleaseWndPtr(pWnd);
2023 WIN_ReleaseWndPtr(pWndCtrl);
2024 WIN_ReleaseWndPtr(pWndDlg);
2030 /***********************************************************************
2031 * GetNextDlgTabItem16 (USER.228)
2033 HWND16 WINAPI GetNextDlgTabItem16( HWND16 hwndDlg, HWND16 hwndCtrl,
2036 return (HWND16)GetNextDlgTabItem( hwndDlg, hwndCtrl, fPrevious );
2039 /***********************************************************************
2040 * DIALOG_GetNextTabItem
2042 * Helper for GetNextDlgTabItem
2044 static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
2048 UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
2050 HWND hChildFirst = 0;
2054 hChildFirst = GetWindow(hwndDlg,GW_CHILD);
2055 if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
2059 HWND hParent = GetParent(hwndCtrl);
2060 BOOL bValid = FALSE;
2063 if(hParent == hwndMain)
2068 hParent = GetParent(hParent);
2072 hChildFirst = GetWindow(hwndCtrl,wndSearch);
2075 if(GetParent(hwndCtrl) != hwndMain)
2076 hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
2080 hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST);
2082 hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST);
2092 dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
2093 exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
2094 if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
2099 else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
2101 hChildFirst = GetWindow(hChildFirst,wndSearch);
2106 retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,(HWND)NULL,fPrevious );
2108 retWnd = hChildFirst;
2111 hChildFirst = GetWindow(hChildFirst,wndSearch);
2113 if(!retWnd && hwndCtrl)
2115 HWND hParent = GetParent(hwndCtrl);
2118 if(hParent == hwndMain) break;
2119 retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
2121 hParent = GetParent(hParent);
2124 retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,(HWND)NULL,fPrevious );
2129 /***********************************************************************
2130 * GetNextDlgTabItem (USER32.276)
2132 HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
2135 return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious);
2138 /**********************************************************************
2139 * DIALOG_DlgDirSelect
2141 * Helper function for DlgDirSelect*
2143 static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
2144 INT id, BOOL win32, BOOL unicode,
2150 HWND listbox = GetDlgItem( hwnd, id );
2152 TRACE("%04x '%s' %d\n", hwnd, str, id );
2153 if (!listbox) return FALSE;
2156 item = SendMessageA(listbox, combo ? CB_GETCURSEL
2157 : LB_GETCURSEL, 0, 0 );
2158 if (item == LB_ERR) return FALSE;
2159 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN
2160 : LB_GETTEXTLEN, 0, 0 );
2161 if (size == LB_ERR) return FALSE;
2165 item = SendMessageA(listbox, combo ? CB_GETCURSEL16
2166 : LB_GETCURSEL16, 0, 0 );
2167 if (item == LB_ERR) return FALSE;
2168 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN16
2169 : LB_GETTEXTLEN16, 0, 0 );
2170 if (size == LB_ERR) return FALSE;
2173 if (!(buffer = SEGPTR_ALLOC( size+1 ))) return FALSE;
2176 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT,
2177 item, (LPARAM)buffer );
2179 SendMessage16( listbox, combo ? CB_GETLBTEXT16 : LB_GETTEXT16,
2180 item, (LPARAM)SEGPTR_GET(buffer) );
2182 if ((ret = (buffer[0] == '['))) /* drive or directory */
2184 if (buffer[1] == '-') /* drive */
2192 buffer[strlen(buffer)-1] = '\\';
2198 if (unicode) lstrcpynAtoW( (LPWSTR)str, ptr, len );
2199 else lstrcpynA( str, ptr, len );
2200 SEGPTR_FREE( buffer );
2201 TRACE("Returning %d '%s'\n", ret, str );
2206 /**********************************************************************
2209 * Helper function for DlgDirList*
2211 static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
2212 INT idStatic, UINT attrib, BOOL combo )
2216 LPSTR orig_spec = spec;
2218 #define SENDMSG(msg,wparam,lparam) \
2219 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
2220 : SendMessageA( hwnd, msg, wparam, lparam ))
2222 TRACE("%04x '%s' %d %d %04x\n",
2223 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
2225 if (spec && spec[0] && (spec[1] == ':'))
2227 drive = toupper( spec[0] ) - 'A';
2229 if (!DRIVE_SetCurrentDrive( drive )) return FALSE;
2231 else drive = DRIVE_GetCurrentDrive();
2233 /* If the path exists and is a directory, chdir to it */
2234 if (!spec || !spec[0] || DRIVE_Chdir( drive, spec )) spec = "*.*";
2239 if ((p2 = strrchr( p, '\\' ))) p = p2;
2240 if ((p2 = strrchr( p, '/' ))) p = p2;
2245 if (!DRIVE_Chdir( drive, spec ))
2247 *p = sep; /* Restore the original spec */
2254 TRACE("path=%c:\\%s mask=%s\n",
2255 'A' + drive, DRIVE_GetDosCwd(drive), spec );
2257 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
2259 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
2260 if (attrib & DDL_DIRECTORY)
2262 if (!(attrib & DDL_EXCLUSIVE))
2264 if (SENDMSG( combo ? CB_DIR : LB_DIR,
2265 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
2266 (LPARAM)spec ) == LB_ERR)
2269 if (SENDMSG( combo ? CB_DIR : LB_DIR,
2270 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
2271 (LPARAM)"*.*" ) == LB_ERR)
2276 if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
2277 (LPARAM)spec ) == LB_ERR)
2282 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
2285 int drive = DRIVE_GetCurrentDrive();
2286 strcpy( temp, "A:\\" );
2288 lstrcpynA( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
2290 /* Can't use PostMessage() here, because the string is on the stack */
2291 SetDlgItemTextA( hDlg, idStatic, temp );
2294 if (orig_spec && (spec != orig_spec))
2296 /* Update the original file spec */
2298 while ((*orig_spec++ = *p++));
2306 /**********************************************************************
2307 * DIALOG_DlgDirListW
2309 * Helper function for DlgDirList*W
2311 static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2312 INT idStatic, UINT attrib, BOOL combo )
2316 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
2317 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
2319 lstrcpyAtoW( spec, specA );
2320 HeapFree( GetProcessHeap(), 0, specA );
2323 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
2327 /**********************************************************************
2328 * DlgDirSelect (USER.99)
2330 BOOL16 WINAPI DlgDirSelect16( HWND16 hwnd, LPSTR str, INT16 id )
2332 return DlgDirSelectEx16( hwnd, str, 128, id );
2336 /**********************************************************************
2337 * DlgDirSelectComboBox (USER.194)
2339 BOOL16 WINAPI DlgDirSelectComboBox16( HWND16 hwnd, LPSTR str, INT16 id )
2341 return DlgDirSelectComboBoxEx16( hwnd, str, 128, id );
2345 /**********************************************************************
2346 * DlgDirSelectEx16 (USER.422)
2348 BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id )
2350 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, FALSE );
2354 /**********************************************************************
2355 * DlgDirSelectExA (USER32.149)
2357 BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id )
2359 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, FALSE );
2363 /**********************************************************************
2364 * DlgDirSelectExW (USER32.150)
2366 BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id )
2368 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, FALSE );
2372 /**********************************************************************
2373 * DlgDirSelectComboBoxEx16 (USER.423)
2375 BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len,
2378 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE, TRUE );
2382 /**********************************************************************
2383 * DlgDirSelectComboBoxExA (USER32.147)
2385 BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len,
2388 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE, TRUE );
2392 /**********************************************************************
2393 * DlgDirSelectComboBoxExW (USER32.148)
2395 BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len,
2398 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE, TRUE );
2402 /**********************************************************************
2403 * DlgDirList16 (USER.100)
2405 INT16 WINAPI DlgDirList16( HWND16 hDlg, LPSTR spec, INT16 idLBox,
2406 INT16 idStatic, UINT16 attrib )
2408 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2412 /**********************************************************************
2413 * DlgDirListA (USER32.143)
2415 INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
2416 INT idStatic, UINT attrib )
2418 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2422 /**********************************************************************
2423 * DlgDirListW (USER32.146)
2425 INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2426 INT idStatic, UINT attrib )
2428 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2432 /**********************************************************************
2433 * DlgDirListComboBox16 (USER.195)
2435 INT16 WINAPI DlgDirListComboBox16( HWND16 hDlg, LPSTR spec, INT16 idCBox,
2436 INT16 idStatic, UINT16 attrib )
2438 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2442 /**********************************************************************
2443 * DlgDirListComboBoxA (USER32.144)
2445 INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox,
2446 INT idStatic, UINT attrib )
2448 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2452 /**********************************************************************
2453 * DlgDirListComboBoxW (USER32.145)
2455 INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox,
2456 INT idStatic, UINT attrib )
2458 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );