Added ctrl-c support.
[wine.git] / windows / dialog.c
blob453c8f02f0d078bfc058ef99e5f6a4b62acd24c9
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 "wine/unicode.h"
40 #include "controls.h"
41 #include "heap.h"
42 #include "win.h"
43 #include "user.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(dialog);
49 /* Dialog control information */
50 typedef struct
52 DWORD style;
53 DWORD exStyle;
54 DWORD helpId;
55 INT16 x;
56 INT16 y;
57 INT16 cx;
58 INT16 cy;
59 UINT id;
60 LPCSTR className;
61 LPCSTR windowName;
62 LPCVOID data;
63 } DLG_CONTROL_INFO;
65 /* Dialog template */
66 typedef struct
68 DWORD style;
69 DWORD exStyle;
70 DWORD helpId;
71 UINT16 nbItems;
72 INT16 x;
73 INT16 y;
74 INT16 cx;
75 INT16 cy;
76 LPCSTR menuName;
77 LPCSTR className;
78 LPCSTR caption;
79 WORD pointSize;
80 WORD weight;
81 BOOL italic;
82 LPCSTR faceName;
83 BOOL dialogEx;
84 } DLG_TEMPLATE;
86 /* Radio button group */
87 typedef struct
89 UINT firstID;
90 UINT lastID;
91 UINT checkID;
92 } RADIOGROUP;
94 /* Dialog base units */
95 static WORD xBaseUnit = 0, yBaseUnit = 0;
98 /*********************************************************************
99 * dialog class descriptor
101 const struct builtin_class_descr DIALOG_builtin_class =
103 DIALOG_CLASS_ATOM, /* name */
104 CS_GLOBALCLASS | CS_SAVEBITS, /* style */
105 DefDlgProcA, /* procA */
106 DefDlgProcW, /* procW */
107 DLGWINDOWEXTRA, /* extra */
108 IDC_ARROWA, /* cursor */
109 0 /* brush */
113 /***********************************************************************
114 * DIALOG_EnableOwner
116 * Helper function for modal dialogs to enable again the
117 * owner of the dialog box.
119 void DIALOG_EnableOwner( HWND hOwner )
121 /* Owner must be a top-level window */
122 if (hOwner)
123 hOwner = GetAncestor( hOwner, GA_ROOT );
124 if (!hOwner) return;
125 EnableWindow( hOwner, TRUE );
129 /***********************************************************************
130 * DIALOG_DisableOwner
132 * Helper function for modal dialogs to disable the
133 * owner of the dialog box. Returns TRUE if owner was enabled.
135 BOOL DIALOG_DisableOwner( HWND hOwner )
137 /* Owner must be a top-level window */
138 if (hOwner)
139 hOwner = GetAncestor( hOwner, GA_ROOT );
140 if (!hOwner) return FALSE;
141 if (IsWindowEnabled( hOwner ))
143 EnableWindow( hOwner, FALSE );
144 return TRUE;
146 else
147 return FALSE;
150 /***********************************************************************
151 * DIALOG_GetCharSizeFromDC
153 * Despite most of MSDN insisting that the horizontal base unit is
154 * tmAveCharWidth it isn't. Knowledge base article Q145994
155 * "HOWTO: Calculate Dialog Units When Not Using the System Font",
156 * says that we should take the average of the 52 English upper and lower
157 * case characters.
159 static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
161 HFONT hFontPrev = 0;
162 char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
163 SIZE sz;
164 TEXTMETRICA tm;
166 pSize->cx = xBaseUnit;
167 pSize->cy = yBaseUnit;
169 if(!hDC) return FALSE;
171 if(hFont) hFontPrev = SelectFont(hDC, hFont);
172 if(!GetTextMetricsA(hDC, &tm)) return FALSE;
173 if(!GetTextExtentPointA(hDC, alphabet, 52, &sz)) return FALSE;
175 pSize->cy = tm.tmHeight;
176 pSize->cx = (sz.cx / 26 + 1) / 2;
178 if (hFontPrev) SelectFont(hDC, hFontPrev);
180 TRACE("dlg base units: %ld x %ld\n", pSize->cx, pSize->cy);
181 return TRUE;
184 /***********************************************************************
185 * DIALOG_GetCharSize
187 * A convenient variant of DIALOG_GetCharSizeFromDC.
189 static BOOL DIALOG_GetCharSize( HFONT hFont, SIZE * pSize )
191 HDC hDC = GetDC(0);
192 BOOL Success = DIALOG_GetCharSizeFromDC( hDC, hFont, pSize );
193 ReleaseDC(0, hDC);
194 return Success;
197 /***********************************************************************
198 * DIALOG_Init
200 * Initialisation of the dialog manager.
202 BOOL DIALOG_Init(void)
204 HDC hdc;
205 SIZE size;
207 /* Calculate the dialog base units */
209 if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL )))
211 ERR("Could not create Display DC\n");
212 return FALSE;
215 if (!DIALOG_GetCharSizeFromDC( hdc, 0, &size ))
217 DeleteDC( hdc );
218 ERR("Could not initialize base dialog units\n");
219 return FALSE;
222 DeleteDC( hdc );
223 xBaseUnit = size.cx;
224 yBaseUnit = size.cy;
226 TRACE("base units = %d,%d\n", xBaseUnit, yBaseUnit );
227 return TRUE;
231 /***********************************************************************
232 * DIALOG_GetControl16
234 * Return the class and text of the control pointed to by ptr,
235 * fill the header structure and return a pointer to the next control.
237 static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
239 static char buffer[10];
240 int int_id;
242 info->x = GET_WORD(p); p += sizeof(WORD);
243 info->y = GET_WORD(p); p += sizeof(WORD);
244 info->cx = GET_WORD(p); p += sizeof(WORD);
245 info->cy = GET_WORD(p); p += sizeof(WORD);
246 info->id = GET_WORD(p); p += sizeof(WORD);
247 info->style = GET_DWORD(p); p += sizeof(DWORD);
248 info->exStyle = 0;
250 if (*p & 0x80)
252 switch((BYTE)*p)
254 case 0x80: strcpy( buffer, "BUTTON" ); break;
255 case 0x81: strcpy( buffer, "EDIT" ); break;
256 case 0x82: strcpy( buffer, "STATIC" ); break;
257 case 0x83: strcpy( buffer, "LISTBOX" ); break;
258 case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
259 case 0x85: strcpy( buffer, "COMBOBOX" ); break;
260 default: buffer[0] = '\0'; break;
262 info->className = buffer;
263 p++;
265 else
267 info->className = p;
268 p += strlen(p) + 1;
271 int_id = ((BYTE)*p == 0xff);
272 if (int_id)
274 /* Integer id, not documented (?). Only works for SS_ICON controls */
275 info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
276 p += 3;
278 else
280 info->windowName = p;
281 p += strlen(p) + 1;
284 if (*p) info->data = p + 1;
285 else info->data = NULL;
287 p += *p + 1;
289 if(int_id)
290 TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %p\n",
291 info->className, LOWORD(info->windowName),
292 info->id, info->x, info->y, info->cx, info->cy,
293 info->style, info->data );
294 else
295 TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %p\n",
296 info->className, info->windowName,
297 info->id, info->x, info->y, info->cx, info->cy,
298 info->style, info->data );
300 return p;
304 /***********************************************************************
305 * DIALOG_GetControl32
307 * Return the class and text of the control pointed to by ptr,
308 * fill the header structure and return a pointer to the next control.
310 static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
311 BOOL dialogEx )
313 if (dialogEx)
315 info->helpId = GET_DWORD(p); p += 2;
316 info->exStyle = GET_DWORD(p); p += 2;
317 info->style = GET_DWORD(p); p += 2;
319 else
321 info->helpId = 0;
322 info->style = GET_DWORD(p); p += 2;
323 info->exStyle = GET_DWORD(p); p += 2;
325 info->x = GET_WORD(p); p++;
326 info->y = GET_WORD(p); p++;
327 info->cx = GET_WORD(p); p++;
328 info->cy = GET_WORD(p); p++;
330 if (dialogEx)
332 /* id is a DWORD for DIALOGEX */
333 info->id = GET_DWORD(p);
334 p += 2;
336 else
338 info->id = GET_WORD(p);
339 p++;
342 if (GET_WORD(p) == 0xffff)
344 static const WCHAR class_names[6][10] =
346 { 'B','u','t','t','o','n', }, /* 0x80 */
347 { 'E','d','i','t', }, /* 0x81 */
348 { 'S','t','a','t','i','c', }, /* 0x82 */
349 { 'L','i','s','t','B','o','x', }, /* 0x83 */
350 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
351 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
353 WORD id = GET_WORD(p+1);
354 if ((id >= 0x80) && (id <= 0x85))
355 info->className = (LPCSTR)class_names[id - 0x80];
356 else
358 info->className = NULL;
359 ERR("Unknown built-in class id %04x\n", id );
361 p += 2;
363 else
365 info->className = (LPCSTR)p;
366 p += strlenW( (LPCWSTR)p ) + 1;
369 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
371 info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1);
372 p += 2;
374 else
376 info->windowName = (LPCSTR)p;
377 p += strlenW( (LPCWSTR)p ) + 1;
380 TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
381 debugstr_w( (LPCWSTR)info->className ),
382 debugstr_w( (LPCWSTR)info->windowName ),
383 info->id, info->x, info->y, info->cx, info->cy,
384 info->style, info->exStyle, info->helpId );
386 if (GET_WORD(p))
388 if (TRACE_ON(dialog))
390 WORD i, count = GET_WORD(p) / sizeof(WORD);
391 TRACE(" BEGIN\n");
392 TRACE(" ");
393 for (i = 0; i < count; i++) DPRINTF( "%04x,", GET_WORD(p+i+1) );
394 DPRINTF("\n");
395 TRACE(" END\n" );
397 info->data = p + 1;
398 p += GET_WORD(p) / sizeof(WORD);
400 else info->data = NULL;
401 p++;
403 /* Next control is on dword boundary */
404 return (const WORD *)((((int)p) + 3) & ~3);
408 /***********************************************************************
409 * DIALOG_CreateControls
411 * Create the control windows for a dialog.
413 static BOOL DIALOG_CreateControls( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate,
414 HINSTANCE hInst, BOOL win32 )
416 DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd );
417 DLG_CONTROL_INFO info;
418 HWND hwndCtrl, hwndDefButton = 0;
419 INT items = dlgTemplate->nbItems;
421 TRACE(" BEGIN\n" );
422 while (items--)
424 if (!win32)
426 HINSTANCE16 instance;
427 SEGPTR segptr;
429 template = DIALOG_GetControl16( template, &info );
430 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
431 !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT))
433 if (!dlgInfo->hDialogHeap)
435 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
436 if (!dlgInfo->hDialogHeap)
438 ERR("Insufficient memory to create heap for edit control\n" );
439 continue;
441 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
443 instance = dlgInfo->hDialogHeap;
445 else instance = (HINSTANCE16)hInst;
447 segptr = MapLS( info.data );
448 hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
449 info.className, info.windowName,
450 info.style | WS_CHILD,
451 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
452 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
453 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
454 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
455 WIN_Handle16(hwnd), (HMENU16)info.id,
456 instance, (LPVOID)segptr ));
457 UnMapLS( segptr );
459 else
461 template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
462 dlgTemplate->dialogEx );
463 /* Is this it? */
464 if (info.style & WS_BORDER)
466 info.style &= ~WS_BORDER;
467 info.exStyle |= WS_EX_CLIENTEDGE;
469 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY,
470 (LPCWSTR)info.className,
471 (LPCWSTR)info.windowName,
472 info.style | WS_CHILD,
473 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
474 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
475 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
476 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
477 hwnd, (HMENU)info.id,
478 hInst, (LPVOID)info.data );
480 if (!hwndCtrl) return FALSE;
482 /* Send initialisation messages to the control */
483 if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
484 (WPARAM)dlgInfo->hUserFont, 0 );
485 if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
487 /* If there's already a default push-button, set it back */
488 /* to normal and use this one instead. */
489 if (hwndDefButton)
490 SendMessageA( hwndDefButton, BM_SETSTYLE,
491 BS_PUSHBUTTON,FALSE );
492 hwndDefButton = hwndCtrl;
493 dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
496 TRACE(" END\n" );
497 return TRUE;
501 /***********************************************************************
502 * DIALOG_ParseTemplate16
504 * Fill a DLG_TEMPLATE structure from the dialog template, and return
505 * a pointer to the first control.
507 static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
509 result->style = GET_DWORD(p); p += sizeof(DWORD);
510 result->exStyle = 0;
511 result->nbItems = (unsigned char) *p++;
512 result->x = GET_WORD(p); p += sizeof(WORD);
513 result->y = GET_WORD(p); p += sizeof(WORD);
514 result->cx = GET_WORD(p); p += sizeof(WORD);
515 result->cy = GET_WORD(p); p += sizeof(WORD);
516 TRACE("DIALOG %d, %d, %d, %d\n",
517 result->x, result->y, result->cx, result->cy );
518 TRACE(" STYLE %08lx\n", result->style );
520 /* Get the menu name */
522 switch( (BYTE)*p )
524 case 0:
525 result->menuName = 0;
526 p++;
527 break;
528 case 0xff:
529 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
530 p += 3;
531 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
532 break;
533 default:
534 result->menuName = p;
535 TRACE(" MENU '%s'\n", p );
536 p += strlen(p) + 1;
537 break;
540 /* Get the class name */
542 if (*p)
544 result->className = p;
545 TRACE(" CLASS '%s'\n", result->className );
547 else result->className = DIALOG_CLASS_ATOM;
548 p += strlen(p) + 1;
550 /* Get the window caption */
552 result->caption = p;
553 p += strlen(p) + 1;
554 TRACE(" CAPTION '%s'\n", result->caption );
556 /* Get the font name */
558 if (result->style & DS_SETFONT)
560 result->pointSize = GET_WORD(p);
561 p += sizeof(WORD);
562 result->faceName = p;
563 p += strlen(p) + 1;
564 TRACE(" FONT %d,'%s'\n",
565 result->pointSize, result->faceName );
567 return p;
571 /***********************************************************************
572 * DIALOG_ParseTemplate32
574 * Fill a DLG_TEMPLATE structure from the dialog template, and return
575 * a pointer to the first control.
577 static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
579 const WORD *p = (const WORD *)template;
581 result->style = GET_DWORD(p); p += 2;
582 if (result->style == 0xffff0001) /* DIALOGEX resource */
584 result->dialogEx = TRUE;
585 result->helpId = GET_DWORD(p); p += 2;
586 result->exStyle = GET_DWORD(p); p += 2;
587 result->style = GET_DWORD(p); p += 2;
589 else
591 result->dialogEx = FALSE;
592 result->helpId = 0;
593 result->exStyle = GET_DWORD(p); p += 2;
595 result->nbItems = GET_WORD(p); p++;
596 result->x = GET_WORD(p); p++;
597 result->y = GET_WORD(p); p++;
598 result->cx = GET_WORD(p); p++;
599 result->cy = GET_WORD(p); p++;
600 TRACE("DIALOG%s %d, %d, %d, %d, %ld\n",
601 result->dialogEx ? "EX" : "", result->x, result->y,
602 result->cx, result->cy, result->helpId );
603 TRACE(" STYLE 0x%08lx\n", result->style );
604 TRACE(" EXSTYLE 0x%08lx\n", result->exStyle );
606 /* Get the menu name */
608 switch(GET_WORD(p))
610 case 0x0000:
611 result->menuName = NULL;
612 p++;
613 break;
614 case 0xffff:
615 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
616 p += 2;
617 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
618 break;
619 default:
620 result->menuName = (LPCSTR)p;
621 TRACE(" MENU %s\n", debugstr_w( (LPCWSTR)p ));
622 p += strlenW( (LPCWSTR)p ) + 1;
623 break;
626 /* Get the class name */
628 switch(GET_WORD(p))
630 case 0x0000:
631 result->className = DIALOG_CLASS_ATOM;
632 p++;
633 break;
634 case 0xffff:
635 result->className = (LPCSTR)(UINT)GET_WORD( p + 1 );
636 p += 2;
637 TRACE(" CLASS %04x\n", LOWORD(result->className) );
638 break;
639 default:
640 result->className = (LPCSTR)p;
641 TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR)p ));
642 p += strlenW( (LPCWSTR)p ) + 1;
643 break;
646 /* Get the window caption */
648 result->caption = (LPCSTR)p;
649 p += strlenW( (LPCWSTR)p ) + 1;
650 TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) );
652 /* Get the font name */
654 if (result->style & DS_SETFONT)
656 result->pointSize = GET_WORD(p);
657 p++;
658 if (result->dialogEx)
660 result->weight = GET_WORD(p); p++;
661 result->italic = LOBYTE(GET_WORD(p)); p++;
663 else
665 result->weight = FW_DONTCARE;
666 result->italic = FALSE;
668 result->faceName = (LPCSTR)p;
669 p += strlenW( (LPCWSTR)p ) + 1;
670 TRACE(" FONT %d, %s, %d, %s\n",
671 result->pointSize, debugstr_w( (LPCWSTR)result->faceName ),
672 result->weight, result->italic ? "TRUE" : "FALSE" );
675 /* First control is on dword boundary */
676 return (LPCSTR)((((int)p) + 3) & ~3);
680 /***********************************************************************
681 * DIALOG_CreateIndirect
682 * Creates a dialog box window
684 * modal = TRUE if we are called from a modal dialog box.
685 * (it's more compatible to do it here, as under Windows the owner
686 * is never disabled if the dialog fails because of an invalid template)
688 static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
689 HWND owner, DLGPROC dlgProc, LPARAM param,
690 WINDOWPROCTYPE procType, BOOL modal )
692 HWND hwnd;
693 RECT rect;
694 WND * wndPtr;
695 DLG_TEMPLATE template;
696 DIALOGINFO * dlgInfo;
697 BOOL ownerEnabled = TRUE;
698 BOOL win32Template = (procType != WIN_PROC_16);
700 /* Parse dialog template */
702 if (!dlgTemplate) return 0;
703 if (win32Template)
704 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
705 else
706 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
708 /* Initialise dialog extra data */
710 if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return 0;
711 dlgInfo->hwndFocus = 0;
712 dlgInfo->hUserFont = 0;
713 dlgInfo->hMenu = 0;
714 dlgInfo->xBaseUnit = xBaseUnit;
715 dlgInfo->yBaseUnit = yBaseUnit;
716 dlgInfo->idResult = 0;
717 dlgInfo->flags = 0;
718 dlgInfo->hDialogHeap = 0;
720 /* Load menu */
722 if (template.menuName)
724 if (!win32Template) dlgInfo->hMenu = LoadMenu16( hInst, template.menuName );
725 else dlgInfo->hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName );
728 /* Create custom font if needed */
730 if (template.style & DS_SETFONT)
732 /* We convert the size to pixels and then make it -ve. This works
733 * for both +ve and -ve template.pointSize */
734 HDC dc;
735 int pixels;
736 dc = GetDC(0);
737 pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72);
738 ReleaseDC(0, dc);
739 if (win32Template)
740 dlgInfo->hUserFont = CreateFontW( -pixels, 0, 0, 0, template.weight,
741 template.italic, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
742 PROOF_QUALITY, FF_DONTCARE,
743 (LPCWSTR)template.faceName );
744 else
745 dlgInfo->hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
746 FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
747 PROOF_QUALITY, FF_DONTCARE, template.faceName );
748 if (dlgInfo->hUserFont)
750 SIZE charSize;
751 if (DIALOG_GetCharSize( dlgInfo->hUserFont, &charSize ))
753 dlgInfo->xBaseUnit = charSize.cx;
754 dlgInfo->yBaseUnit = charSize.cy;
757 TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit );
760 /* Create dialog main window */
762 rect.left = rect.top = 0;
763 rect.right = MulDiv(template.cx, dlgInfo->xBaseUnit, 4);
764 rect.bottom = MulDiv(template.cy, dlgInfo->yBaseUnit, 8);
765 if (template.style & DS_MODALFRAME)
766 template.exStyle |= WS_EX_DLGMODALFRAME;
767 AdjustWindowRectEx( &rect, template.style, (dlgInfo->hMenu != 0), template.exStyle );
768 rect.right -= rect.left;
769 rect.bottom -= rect.top;
771 if ((INT16)template.x == CW_USEDEFAULT16)
773 rect.left = rect.top = win32Template? CW_USEDEFAULT : CW_USEDEFAULT16;
775 else
777 if (template.style & DS_CENTER)
779 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
780 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
782 else
784 rect.left += MulDiv(template.x, dlgInfo->xBaseUnit, 4);
785 rect.top += MulDiv(template.y, dlgInfo->yBaseUnit, 8);
787 if ( !(template.style & WS_CHILD) )
789 INT16 dX, dY;
791 if( !(template.style & DS_ABSALIGN) )
792 ClientToScreen( owner, (POINT *)&rect );
794 /* try to fit it into the desktop */
796 if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME)
797 - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX;
798 if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME)
799 - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY;
800 if( rect.left < 0 ) rect.left = 0;
801 if( rect.top < 0 ) rect.top = 0;
805 if (modal)
807 ownerEnabled = DIALOG_DisableOwner( owner );
808 if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED;
811 if (!win32Template)
812 hwnd = WIN_Handle32( CreateWindowEx16(template.exStyle, template.className,
813 template.caption, template.style & ~WS_VISIBLE,
814 rect.left, rect.top, rect.right, rect.bottom,
815 WIN_Handle16(owner), dlgInfo->hMenu, hInst, NULL ));
816 else
817 hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className,
818 (LPCWSTR)template.caption,
819 template.style & ~WS_VISIBLE,
820 rect.left, rect.top, rect.right, rect.bottom,
821 owner, dlgInfo->hMenu, hInst, NULL );
823 if (!hwnd)
825 if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
826 if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );
827 if (modal && (dlgInfo->flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
828 HeapFree( GetProcessHeap(), 0, dlgInfo );
829 return 0;
831 wndPtr = WIN_GetPtr( hwnd );
832 wndPtr->flags |= WIN_ISDIALOG;
833 WIN_ReleasePtr( wndPtr );
835 if (template.helpId) SetWindowContextHelpId( hwnd, template.helpId );
836 SetWindowLongW( hwnd, DWL_WINE_DIALOGINFO, (LONG)dlgInfo );
837 switch(procType)
839 case WIN_PROC_16: SetWindowLong16( WIN_Handle16(hwnd), DWL_DLGPROC, (LONG)dlgProc ); break;
840 case WIN_PROC_32A: SetWindowLongA( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
841 case WIN_PROC_32W: SetWindowLongW( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
842 default: break;
845 if (dlgInfo->hUserFont)
846 SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
848 /* Create controls */
850 if (DIALOG_CreateControls( hwnd, dlgTemplate, &template,
851 hInst, win32Template ))
853 HWND hwndPreInitFocus;
855 /* Send initialisation messages and set focus */
857 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
859 hwndPreInitFocus = GetFocus();
860 if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
862 /* check where the focus is again,
863 * some controls status might have changed in WM_INITDIALOG */
864 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
865 if( dlgInfo->hwndFocus )
866 SetFocus( dlgInfo->hwndFocus );
868 else
870 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
871 but the focus has not changed, set the focus where we expect it. */
872 if ((GetFocus() == hwndPreInitFocus) &&
873 (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
875 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
876 if( dlgInfo->hwndFocus )
877 SetFocus( dlgInfo->hwndFocus );
881 if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
883 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
885 return hwnd;
887 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
888 if (modal && ownerEnabled) DIALOG_EnableOwner(owner);
889 return 0;
893 /***********************************************************************
894 * CreateDialog (USER.89)
896 HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
897 HWND16 owner, DLGPROC16 dlgProc )
899 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
903 /***********************************************************************
904 * CreateDialogParam (USER.241)
906 HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
907 HWND16 owner, DLGPROC16 dlgProc,
908 LPARAM param )
910 HWND16 hwnd = 0;
911 HRSRC16 hRsrc;
912 HGLOBAL16 hmem;
913 LPCVOID data;
915 TRACE("%04x,%s,%04x,%08lx,%ld\n",
916 hInst, debugstr_a(dlgTemplate), owner, (DWORD)dlgProc, param );
918 if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOGA ))) return 0;
919 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
920 if (!(data = LockResource16( hmem ))) hwnd = 0;
921 else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
922 dlgProc, param );
923 FreeResource16( hmem );
924 return hwnd;
927 /***********************************************************************
928 * CreateDialogParamA (USER32.@)
930 HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name,
931 HWND owner, DLGPROC dlgProc,
932 LPARAM param )
934 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
935 if (!hrsrc) return 0;
936 return CreateDialogIndirectParamA( hInst,
937 (LPVOID)LoadResource(hInst, hrsrc),
938 owner, dlgProc, param );
942 /***********************************************************************
943 * CreateDialogParamW (USER32.@)
945 HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name,
946 HWND owner, DLGPROC dlgProc,
947 LPARAM param )
949 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
950 if (!hrsrc) return 0;
951 return CreateDialogIndirectParamW( hInst,
952 (LPVOID)LoadResource(hInst, hrsrc),
953 owner, dlgProc, param );
957 /***********************************************************************
958 * CreateDialogIndirect (USER.219)
960 HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
961 HWND16 owner, DLGPROC16 dlgProc )
963 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
967 /***********************************************************************
968 * CreateDialogIndirectParam (USER.242)
969 * CreateDialogIndirectParam16 (USER32.@)
971 HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst,
972 LPCVOID dlgTemplate,
973 HWND16 owner, DLGPROC16 dlgProc,
974 LPARAM param )
976 return WIN_Handle16( DIALOG_CreateIndirect( hInst, dlgTemplate, WIN_Handle32(owner),
977 (DLGPROC)dlgProc, param, WIN_PROC_16, FALSE ));
981 /***********************************************************************
982 * CreateDialogIndirectParamA (USER32.@)
984 HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst,
985 LPCVOID dlgTemplate,
986 HWND owner, DLGPROC dlgProc,
987 LPARAM param )
989 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32A, FALSE );
992 /***********************************************************************
993 * CreateDialogIndirectParamAorW (USER32.@)
995 HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst,
996 LPCVOID dlgTemplate,
997 HWND owner, DLGPROC dlgProc,
998 LPARAM param )
999 { FIXME("assume WIN_PROC_32W\n");
1000 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
1003 /***********************************************************************
1004 * CreateDialogIndirectParamW (USER32.@)
1006 HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst,
1007 LPCVOID dlgTemplate,
1008 HWND owner, DLGPROC dlgProc,
1009 LPARAM param )
1011 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
1015 /***********************************************************************
1016 * DIALOG_DoDialogBox
1018 static INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
1020 DIALOGINFO * dlgInfo;
1021 MSG msg;
1022 INT retval;
1023 HWND ownerMsg = GetAncestor( owner, GA_ROOT );
1025 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return -1;
1027 if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
1029 ShowWindow( hwnd, SW_SHOW );
1030 for (;;)
1032 if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG))
1034 if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
1036 /* No message present -> send ENTERIDLE and wait */
1037 SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd );
1038 if (!GetMessageW( &msg, 0, 0, 0 )) break;
1041 else if (!GetMessageW( &msg, 0, 0, 0 )) break;
1043 if (CallMsgFilterW( &msg, MSGF_DIALOGBOX )) continue;
1045 if (!IsWindow( hwnd )) return -1;
1046 if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))
1048 TranslateMessage( &msg );
1049 DispatchMessageW( &msg );
1051 if (dlgInfo->flags & DF_END) break;
1054 if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner );
1055 retval = dlgInfo->idResult;
1056 DestroyWindow( hwnd );
1057 return retval;
1061 /***********************************************************************
1062 * DialogBox (USER.87)
1064 INT16 WINAPI DialogBox16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
1065 HWND16 owner, DLGPROC16 dlgProc )
1067 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1071 /***********************************************************************
1072 * DialogBoxParam (USER.239)
1074 INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template,
1075 HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
1077 HWND hwnd = 0;
1078 HRSRC16 hRsrc;
1079 HGLOBAL16 hmem;
1080 LPCVOID data;
1081 int ret = -1;
1083 if (!(hRsrc = FindResource16( hInst, template, RT_DIALOGA ))) return 0;
1084 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
1085 if ((data = LockResource16( hmem )))
1087 HWND owner = WIN_Handle32(owner16);
1088 hwnd = DIALOG_CreateIndirect( hInst, data, owner,
1089 (DLGPROC)dlgProc, param, WIN_PROC_16, TRUE );
1090 if (hwnd) ret = DIALOG_DoDialogBox( hwnd, owner );
1091 GlobalUnlock16( hmem );
1093 FreeResource16( hmem );
1094 return ret;
1098 /***********************************************************************
1099 * DialogBoxParamA (USER32.@)
1101 INT WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
1102 HWND owner, DLGPROC dlgProc, LPARAM param )
1104 HWND hwnd;
1105 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
1106 if (!hrsrc) return 0;
1107 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1108 owner, dlgProc, param, WIN_PROC_32A, TRUE );
1109 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1110 return -1;
1114 /***********************************************************************
1115 * DialogBoxParamW (USER32.@)
1117 INT WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
1118 HWND owner, DLGPROC dlgProc, LPARAM param )
1120 HWND hwnd;
1121 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
1122 if (!hrsrc) return 0;
1123 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1124 owner, dlgProc, param, WIN_PROC_32W, TRUE );
1125 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1126 return -1;
1130 /***********************************************************************
1131 * DialogBoxIndirect (USER.218)
1133 INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1134 HWND16 owner, DLGPROC16 dlgProc )
1136 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1140 /***********************************************************************
1141 * DialogBoxIndirectParam (USER.240)
1142 * DialogBoxIndirectParam16 (USER32.@)
1144 INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1145 HWND16 owner16, DLGPROC16 dlgProc,
1146 LPARAM param )
1148 HWND hwnd, owner = WIN_Handle32( owner16 );
1149 LPCVOID ptr;
1151 if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
1152 hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, (DLGPROC)dlgProc,
1153 param, WIN_PROC_16, TRUE );
1154 GlobalUnlock16( dlgTemplate );
1155 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1156 return -1;
1160 /***********************************************************************
1161 * DialogBoxIndirectParamA (USER32.@)
1163 INT WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCVOID template,
1164 HWND owner, DLGPROC dlgProc,
1165 LPARAM param )
1167 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1168 dlgProc, param, WIN_PROC_32A, TRUE );
1169 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1170 return -1;
1174 /***********************************************************************
1175 * DialogBoxIndirectParamW (USER32.@)
1177 INT WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCVOID template,
1178 HWND owner, DLGPROC dlgProc,
1179 LPARAM param )
1181 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1182 dlgProc, param, WIN_PROC_32W, TRUE );
1183 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1184 return -1;
1187 /***********************************************************************
1188 * DialogBoxIndirectParamAorW (USER32.@)
1190 INT WINAPI DialogBoxIndirectParamAorW(HINSTANCE hInstance, LPCVOID template,
1191 HWND owner, DLGPROC dlgProc,
1192 LPARAM param, DWORD x )
1194 HWND hwnd;
1195 FIXME("0x%08x %p 0x%08x %p 0x%08lx 0x%08lx\n",
1196 hInstance, template, owner, dlgProc, param, x);
1197 hwnd = DIALOG_CreateIndirect( hInstance, template, owner, dlgProc, param, WIN_PROC_32W, TRUE );
1198 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1199 return -1;
1202 /***********************************************************************
1203 * EndDialog (USER32.@)
1205 BOOL WINAPI EndDialog( HWND hwnd, INT retval )
1207 BOOL wasEnabled = TRUE;
1208 DIALOGINFO * dlgInfo;
1209 HWND owner;
1211 TRACE("%04x %d\n", hwnd, retval );
1213 if (!(dlgInfo = DIALOG_get_info( hwnd )))
1215 ERR("got invalid window handle (%04x); buggy app !?\n", hwnd);
1216 return FALSE;
1218 dlgInfo->idResult = retval;
1219 dlgInfo->flags |= DF_END;
1220 wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
1222 if (wasEnabled && (owner = GetWindow( hwnd, GW_OWNER )))
1223 DIALOG_EnableOwner( owner );
1225 /* Windows sets the focus to the dialog itself in EndDialog */
1227 if (IsChild(hwnd, GetFocus()))
1228 SetFocus( hwnd );
1230 /* Don't have to send a ShowWindow(SW_HIDE), just do
1231 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1233 SetWindowPos(hwnd, (HWND)0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
1234 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
1236 /* unblock dialog loop */
1237 PostMessageA(hwnd, WM_NULL, 0, 0);
1238 return TRUE;
1242 /***********************************************************************
1243 * DIALOG_IsAccelerator
1245 static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey )
1247 HWND hwndControl = hwnd;
1248 HWND hwndNext;
1249 INT dlgCode;
1250 WCHAR buffer[128];
1254 DWORD style = GetWindowLongW( hwndControl, GWL_STYLE );
1255 if ((style & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE)
1257 dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
1258 if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
1259 GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) ))
1261 /* find the accelerator key */
1262 LPWSTR p = buffer - 2;
1263 char a_char = vKey;
1264 WCHAR w_char = 0;
1268 p = strchrW( p + 2, '&' );
1270 while (p != NULL && p[1] == '&');
1272 /* and check if it's the one we're looking for */
1273 MultiByteToWideChar(CP_ACP, 0, &a_char, 1, &w_char, 1);
1274 if (p != NULL && toupperW( p[1] ) == toupperW( w_char ) )
1276 if ((dlgCode & DLGC_STATIC) || (style & 0x0f) == BS_GROUPBOX )
1278 /* set focus to the control */
1279 SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, 1);
1280 /* and bump it on to next */
1281 SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
1283 else if (dlgCode & DLGC_BUTTON)
1285 /* send BM_CLICK message to the control */
1286 SendMessageA( hwndControl, BM_CLICK, 0, 0 );
1288 return TRUE;
1291 hwndNext = GetWindow( hwndControl, GW_CHILD );
1293 else hwndNext = 0;
1295 if (!hwndNext) hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1297 while (!hwndNext && hwndControl)
1299 hwndControl = GetParent( hwndControl );
1300 if (hwndControl == hwndDlg)
1302 if(hwnd==hwndDlg) /* prevent endless loop */
1304 hwndNext=hwnd;
1305 break;
1307 hwndNext = GetWindow( hwndDlg, GW_CHILD );
1309 else
1310 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1312 hwndControl = hwndNext;
1314 while (hwndControl && (hwndControl != hwnd));
1316 return FALSE;
1319 /***********************************************************************
1320 * DIALOG_FindMsgDestination
1322 * The messages that IsDialogMessage sends may not go to the dialog
1323 * calling IsDialogMessage if that dialog is a child, and it has the
1324 * DS_CONTROL style set.
1325 * We propagate up until we hit one that does not have DS_CONTROL, or
1326 * whose parent is not a dialog.
1328 * This is undocumented behaviour.
1330 static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
1332 while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL)
1334 WND *pParent;
1335 HWND hParent = GetParent(hwndDlg);
1336 if (!hParent) break;
1338 pParent = WIN_FindWndPtr(hParent);
1339 if (!pParent) break;
1341 if (!(pParent->flags & WIN_ISDIALOG))
1343 WIN_ReleaseWndPtr(pParent);
1344 break;
1346 WIN_ReleaseWndPtr(pParent);
1348 hwndDlg = hParent;
1351 return hwndDlg;
1354 /***********************************************************************
1355 * DIALOG_IsDialogMessage
1357 static BOOL DIALOG_IsDialogMessage( HWND hwnd, HWND hwndDlg,
1358 UINT message, WPARAM wParam,
1359 LPARAM lParam, BOOL *translate,
1360 BOOL *dispatch, INT dlgCode )
1362 *translate = *dispatch = FALSE;
1364 if (message == WM_PAINT)
1366 /* Apparently, we have to handle this one as well */
1367 *dispatch = TRUE;
1368 return TRUE;
1371 /* Only the key messages get special processing */
1372 if ((message != WM_KEYDOWN) &&
1373 (message != WM_SYSKEYDOWN) &&
1374 (message != WM_SYSCHAR) &&
1375 (message != WM_CHAR))
1376 return FALSE;
1378 if (dlgCode & DLGC_WANTMESSAGE)
1380 *translate = *dispatch = TRUE;
1381 return TRUE;
1384 hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
1386 switch(message)
1388 case WM_KEYDOWN:
1389 switch(wParam)
1391 case VK_TAB:
1392 if (!(dlgCode & DLGC_WANTTAB))
1394 SendMessageA( hwndDlg, WM_NEXTDLGCTL,
1395 (GetKeyState(VK_SHIFT) & 0x8000), 0 );
1396 return TRUE;
1398 break;
1400 case VK_RIGHT:
1401 case VK_DOWN:
1402 case VK_LEFT:
1403 case VK_UP:
1404 if (!(dlgCode & DLGC_WANTARROWS))
1406 BOOL fPrevious = (wParam == VK_LEFT || wParam == VK_UP);
1407 HWND hwndNext =
1408 GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious );
1409 SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndNext, 1 );
1410 return TRUE;
1412 break;
1414 case VK_ESCAPE:
1415 SendMessageA( hwndDlg, WM_COMMAND, IDCANCEL,
1416 (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
1417 return TRUE;
1419 case VK_RETURN:
1421 DWORD dw = SendMessageW( hwndDlg, DM_GETDEFID, 0, 0 );
1422 if (HIWORD(dw) == DC_HASDEFID)
1424 SendMessageA( hwndDlg, WM_COMMAND,
1425 MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
1426 (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw)));
1428 else
1430 SendMessageA( hwndDlg, WM_COMMAND, IDOK,
1431 (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
1435 return TRUE;
1437 *translate = TRUE;
1438 break; /* case WM_KEYDOWN */
1440 case WM_CHAR:
1441 if (dlgCode & DLGC_WANTCHARS) break;
1442 /* drop through */
1444 case WM_SYSCHAR:
1445 if (DIALOG_IsAccelerator( WIN_GetFullHandle(hwnd), hwndDlg, wParam ))
1447 /* don't translate or dispatch */
1448 return TRUE;
1450 break;
1452 case WM_SYSKEYDOWN:
1453 *translate = TRUE;
1454 break;
1457 /* If we get here, the message has not been treated specially */
1458 /* and can be sent to its destination window. */
1459 *dispatch = TRUE;
1460 return TRUE;
1464 /***********************************************************************
1465 * IsDialogMessage (USER.90)
1467 BOOL16 WINAPI IsDialogMessage16( HWND16 hwndDlg, SEGPTR msg16 )
1469 LPMSG16 msg = MapSL(msg16);
1470 BOOL ret, translate, dispatch;
1471 INT dlgCode = 0;
1473 if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
1474 return FALSE;
1476 if ((msg->message == WM_KEYDOWN) ||
1477 (msg->message == WM_CHAR))
1479 dlgCode = SendMessage16( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg16);
1481 ret = DIALOG_IsDialogMessage( WIN_Handle32(msg->hwnd), WIN_Handle32(hwndDlg),
1482 msg->message, msg->wParam, msg->lParam,
1483 &translate, &dispatch, dlgCode );
1484 if (translate) TranslateMessage16( msg );
1485 if (dispatch) DispatchMessage16( msg );
1486 return ret;
1490 /***********************************************************************
1491 * IsDialogMessage (USER32.@)
1492 * IsDialogMessageA (USER32.@)
1494 BOOL WINAPI IsDialogMessageA( HWND hwndDlg, LPMSG msg )
1496 BOOL ret, translate, dispatch;
1497 INT dlgCode = 0;
1499 hwndDlg = WIN_GetFullHandle( hwndDlg );
1500 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
1501 return FALSE;
1503 if ((msg->message == WM_KEYDOWN) ||
1504 (msg->message == WM_CHAR))
1506 dlgCode = SendMessageA( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1508 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1509 msg->wParam, msg->lParam,
1510 &translate, &dispatch, dlgCode );
1511 if (translate) TranslateMessage( msg );
1512 if (dispatch) DispatchMessageA( msg );
1513 return ret;
1517 /***********************************************************************
1518 * IsDialogMessageW (USER32.@)
1520 BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
1522 BOOL ret, translate, dispatch;
1523 INT dlgCode = 0;
1525 hwndDlg = WIN_GetFullHandle( hwndDlg );
1526 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
1527 return FALSE;
1529 if ((msg->message == WM_KEYDOWN) ||
1530 (msg->message == WM_CHAR))
1532 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1534 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1535 msg->wParam, msg->lParam,
1536 &translate, &dispatch, dlgCode );
1537 if (translate) TranslateMessage( msg );
1538 if (dispatch) DispatchMessageW( msg );
1539 return ret;
1543 /***********************************************************************
1544 * GetDlgCtrlID (USER32.@)
1546 INT WINAPI GetDlgCtrlID( HWND hwnd )
1548 return GetWindowLongW( hwnd, GWL_ID );
1552 /***********************************************************************
1553 * GetDlgItem (USER32.@)
1555 HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
1557 int i;
1558 HWND *list = WIN_ListChildren( hwndDlg );
1559 HWND ret = 0;
1561 if (!list) return 0;
1563 for (i = 0; list[i]; i++) if (GetWindowLongW( list[i], GWL_ID ) == id) break;
1564 ret = list[i];
1565 HeapFree( GetProcessHeap(), 0, list );
1566 return ret;
1570 /*******************************************************************
1571 * SendDlgItemMessageA (USER32.@)
1573 LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg,
1574 WPARAM wParam, LPARAM lParam )
1576 HWND hwndCtrl = GetDlgItem( hwnd, id );
1577 if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam );
1578 else return 0;
1582 /*******************************************************************
1583 * SendDlgItemMessageW (USER32.@)
1585 LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg,
1586 WPARAM wParam, LPARAM lParam )
1588 HWND hwndCtrl = GetDlgItem( hwnd, id );
1589 if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam );
1590 else return 0;
1594 /*******************************************************************
1595 * SetDlgItemTextA (USER32.@)
1597 BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString )
1599 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1603 /*******************************************************************
1604 * SetDlgItemTextW (USER32.@)
1606 BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString )
1608 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1612 /***********************************************************************
1613 * GetDlgItemTextA (USER32.@)
1615 INT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, UINT len )
1617 return (INT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT,
1618 len, (LPARAM)str );
1622 /***********************************************************************
1623 * GetDlgItemTextW (USER32.@)
1625 INT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, UINT len )
1627 return (INT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT,
1628 len, (LPARAM)str );
1632 /*******************************************************************
1633 * SetDlgItemInt (USER32.@)
1635 BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value,
1636 BOOL fSigned )
1638 char str[20];
1640 if (fSigned) sprintf( str, "%d", (INT)value );
1641 else sprintf( str, "%u", value );
1642 SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
1643 return TRUE;
1647 /***********************************************************************
1648 * GetDlgItemInt (USER32.@)
1650 UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated,
1651 BOOL fSigned )
1653 char str[30];
1654 char * endptr;
1655 long result = 0;
1657 if (translated) *translated = FALSE;
1658 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
1659 return 0;
1660 if (fSigned)
1662 result = strtol( str, &endptr, 10 );
1663 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1664 return 0;
1665 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1666 return 0;
1668 else
1670 result = strtoul( str, &endptr, 10 );
1671 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1672 return 0;
1673 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1675 if (translated) *translated = TRUE;
1676 return (UINT)result;
1680 /***********************************************************************
1681 * CheckDlgButton (USER32.@)
1683 BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check )
1685 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
1686 return TRUE;
1690 /***********************************************************************
1691 * IsDlgButtonChecked (USER32.@)
1693 UINT WINAPI IsDlgButtonChecked( HWND hwnd, UINT id )
1695 return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
1699 /***********************************************************************
1700 * CheckRB
1702 * Callback function used to check/uncheck radio buttons that fall
1703 * within a specific range of IDs.
1705 static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam)
1707 LONG lChildID = GetWindowLongA(hwndChild, GWL_ID);
1708 RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam;
1710 if ((lChildID >= lpRadioGroup->firstID) &&
1711 (lChildID <= lpRadioGroup->lastID))
1713 if (lChildID == lpRadioGroup->checkID)
1715 SendMessageA(hwndChild, BM_SETCHECK, BST_CHECKED, 0);
1717 else
1719 SendMessageA(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0);
1723 return TRUE;
1727 /***********************************************************************
1728 * CheckRadioButton (USER32.@)
1730 BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
1731 UINT lastID, UINT checkID )
1733 RADIOGROUP radioGroup;
1735 /* perform bounds checking for a radio button group */
1736 radioGroup.firstID = min(min(firstID, lastID), checkID);
1737 radioGroup.lastID = max(max(firstID, lastID), checkID);
1738 radioGroup.checkID = checkID;
1740 return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB,
1741 (LPARAM)&radioGroup);
1745 /***********************************************************************
1746 * GetDialogBaseUnits (USER.243)
1747 * GetDialogBaseUnits (USER32.@)
1749 DWORD WINAPI GetDialogBaseUnits(void)
1751 return MAKELONG( xBaseUnit, yBaseUnit );
1755 /***********************************************************************
1756 * MapDialogRect (USER32.@)
1758 BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
1760 DIALOGINFO * dlgInfo;
1761 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return FALSE;
1762 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1763 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1764 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1765 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
1766 return TRUE;
1770 /***********************************************************************
1771 * GetNextDlgGroupItem (USER32.@)
1773 HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1775 HWND hwnd, retvalue;
1777 hwndDlg = WIN_GetFullHandle( hwndDlg );
1778 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1780 if(hwndCtrl)
1782 /* if the hwndCtrl is the child of the control in the hwndDlg,
1783 * then the hwndDlg has to be the parent of the hwndCtrl */
1784 if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg)
1785 hwndDlg = GetParent(hwndCtrl);
1788 if (hwndCtrl)
1790 /* Make sure hwndCtrl is a top-level child */
1791 HWND parent = GetParent( hwndCtrl );
1792 while (parent && parent != hwndDlg) parent = GetParent(parent);
1793 if (parent != hwndDlg) return 0;
1795 else
1797 /* No ctrl specified -> start from the beginning */
1798 if (!(hwndCtrl = GetWindow( hwndDlg, GW_CHILD ))) return 0;
1799 if (fPrevious) hwndCtrl = GetWindow( hwndCtrl, GW_HWNDLAST );
1802 retvalue = hwndCtrl;
1803 hwnd = GetWindow( hwndCtrl, GW_HWNDNEXT );
1804 while (1)
1806 if (!hwnd || (GetWindowLongW( hwnd, GWL_STYLE ) & WS_GROUP))
1808 /* Wrap-around to the beginning of the group */
1809 HWND tmp;
1811 hwnd = GetWindow( hwndDlg, GW_CHILD );
1812 for (tmp = hwnd; tmp; tmp = GetWindow( tmp, GW_HWNDNEXT ) )
1814 if (GetWindowLongW( tmp, GWL_STYLE ) & WS_GROUP) hwnd = tmp;
1815 if (tmp == hwndCtrl) break;
1818 if (hwnd == hwndCtrl) break;
1819 if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE)
1821 retvalue = hwnd;
1822 if (!fPrevious) break;
1824 hwnd = GetWindow( hwnd, GW_HWNDNEXT );
1826 return retvalue;
1830 /***********************************************************************
1831 * DIALOG_GetNextTabItem
1833 * Helper for GetNextDlgTabItem
1835 static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1837 LONG dsStyle;
1838 LONG exStyle;
1839 UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
1840 HWND retWnd = 0;
1841 HWND hChildFirst = 0;
1843 if(!hwndCtrl)
1845 hChildFirst = GetWindow(hwndDlg,GW_CHILD);
1846 if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
1848 else if (IsChild( hwndMain, hwndCtrl ))
1850 hChildFirst = GetWindow(hwndCtrl,wndSearch);
1851 if(!hChildFirst)
1853 if(GetParent(hwndCtrl) != hwndMain)
1854 hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
1855 else
1857 if(fPrevious)
1858 hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST);
1859 else
1860 hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST);
1865 while(hChildFirst)
1867 BOOL bCtrl = FALSE;
1868 while(hChildFirst)
1870 dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
1871 exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
1872 if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1874 bCtrl=TRUE;
1875 break;
1877 else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1878 break;
1879 hChildFirst = GetWindow(hChildFirst,wndSearch);
1881 if(hChildFirst)
1883 if(bCtrl)
1884 retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,(HWND)NULL,fPrevious );
1885 else
1886 retWnd = hChildFirst;
1888 if(retWnd) break;
1889 hChildFirst = GetWindow(hChildFirst,wndSearch);
1891 if(!retWnd && hwndCtrl)
1893 HWND hParent = GetParent(hwndCtrl);
1894 while(hParent)
1896 if(hParent == hwndMain) break;
1897 retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
1898 if(retWnd) break;
1899 hParent = GetParent(hParent);
1901 if(!retWnd)
1902 retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,(HWND)NULL,fPrevious );
1904 return retWnd;
1907 /***********************************************************************
1908 * GetNextDlgTabItem (USER32.@)
1910 HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
1911 BOOL fPrevious )
1913 hwndDlg = WIN_GetFullHandle( hwndDlg );
1914 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1915 return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious);
1918 /**********************************************************************
1919 * DIALOG_DlgDirSelect
1921 * Helper function for DlgDirSelect*
1923 static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
1924 INT id, BOOL unicode, BOOL combo )
1926 char *buffer, *ptr;
1927 INT item, size;
1928 BOOL ret;
1929 HWND listbox = GetDlgItem( hwnd, id );
1931 TRACE("%04x '%s' %d\n", hwnd, str, id );
1932 if (!listbox) return FALSE;
1934 item = SendMessageA(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 );
1935 if (item == LB_ERR) return FALSE;
1936 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN : LB_GETTEXTLEN, 0, 0 );
1937 if (size == LB_ERR) return FALSE;
1939 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size+1 ))) return FALSE;
1941 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, item, (LPARAM)buffer );
1943 if ((ret = (buffer[0] == '['))) /* drive or directory */
1945 if (buffer[1] == '-') /* drive */
1947 buffer[3] = ':';
1948 buffer[4] = 0;
1949 ptr = buffer + 2;
1951 else
1953 buffer[strlen(buffer)-1] = '\\';
1954 ptr = buffer + 1;
1957 else ptr = buffer;
1959 if (unicode)
1961 if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, ptr, -1, (LPWSTR)str, len ))
1962 ((LPWSTR)str)[len-1] = 0;
1964 else lstrcpynA( str, ptr, len );
1965 HeapFree( GetProcessHeap(), 0, buffer );
1966 TRACE("Returning %d '%s'\n", ret, str );
1967 return ret;
1971 /**********************************************************************
1972 * DIALOG_DlgDirList
1974 * Helper function for DlgDirList*
1976 static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
1977 INT idStatic, UINT attrib, BOOL combo )
1979 HWND hwnd;
1980 LPSTR orig_spec = spec;
1982 #define SENDMSG(msg,wparam,lparam) \
1983 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
1984 : SendMessageA( hwnd, msg, wparam, lparam ))
1986 TRACE("%04x '%s' %d %d %04x\n",
1987 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
1989 /* If the path exists and is a directory, chdir to it */
1990 if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = "*.*";
1991 else
1993 char *p, *p2;
1994 p = spec;
1995 if ((p2 = strrchr( p, '\\' ))) p = p2;
1996 if ((p2 = strrchr( p, '/' ))) p = p2;
1997 if (p != spec)
1999 char sep = *p;
2000 *p = 0;
2001 if (!SetCurrentDirectoryA( spec ))
2003 *p = sep; /* Restore the original spec */
2004 return FALSE;
2006 spec = p + 1;
2010 TRACE( "mask=%s\n", spec );
2012 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
2014 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
2015 if (attrib & DDL_DIRECTORY)
2017 if (!(attrib & DDL_EXCLUSIVE))
2019 if (SENDMSG( combo ? CB_DIR : LB_DIR,
2020 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
2021 (LPARAM)spec ) == LB_ERR)
2022 return FALSE;
2024 if (SENDMSG( combo ? CB_DIR : LB_DIR,
2025 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
2026 (LPARAM)"*.*" ) == LB_ERR)
2027 return FALSE;
2029 else
2031 if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
2032 (LPARAM)spec ) == LB_ERR)
2033 return FALSE;
2037 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
2039 char temp[MAX_PATH];
2040 GetCurrentDirectoryA( sizeof(temp), temp );
2041 CharLowerA( temp );
2042 /* Can't use PostMessage() here, because the string is on the stack */
2043 SetDlgItemTextA( hDlg, idStatic, temp );
2046 if (orig_spec && (spec != orig_spec))
2048 /* Update the original file spec */
2049 char *p = spec;
2050 while ((*orig_spec++ = *p++));
2053 return TRUE;
2054 #undef SENDMSG
2058 /**********************************************************************
2059 * DIALOG_DlgDirListW
2061 * Helper function for DlgDirList*W
2063 static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2064 INT idStatic, UINT attrib, BOOL combo )
2066 if (spec)
2068 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
2069 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
2070 attrib, combo );
2071 MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff );
2072 HeapFree( GetProcessHeap(), 0, specA );
2073 return ret;
2075 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
2079 /**********************************************************************
2080 * DlgDirSelectExA (USER32.@)
2082 BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id )
2084 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE );
2088 /**********************************************************************
2089 * DlgDirSelectExW (USER32.@)
2091 BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id )
2093 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, FALSE );
2097 /**********************************************************************
2098 * DlgDirSelectComboBoxExA (USER32.@)
2100 BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len,
2101 INT id )
2103 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, TRUE );
2107 /**********************************************************************
2108 * DlgDirSelectComboBoxExW (USER32.@)
2110 BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len,
2111 INT id)
2113 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE );
2117 /**********************************************************************
2118 * DlgDirListA (USER32.@)
2120 INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
2121 INT idStatic, UINT attrib )
2123 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2127 /**********************************************************************
2128 * DlgDirListW (USER32.@)
2130 INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2131 INT idStatic, UINT attrib )
2133 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2137 /**********************************************************************
2138 * DlgDirListComboBoxA (USER32.@)
2140 INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox,
2141 INT idStatic, UINT attrib )
2143 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2147 /**********************************************************************
2148 * DlgDirListComboBoxW (USER32.@)
2150 INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox,
2151 INT idStatic, UINT attrib )
2153 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );