A couple of optimizations.
[wine/multimedia.git] / windows / dialog.c
blob576a75ead0fb15bd47cdf66f662f5b2732f1d129
1 /*
2 * Dialog functions
4 * Copyright 1993, 1994, 1996 Alexandre Julliard
5 */
7 #include "wine/port.h"
9 #include <ctype.h>
10 #include <errno.h>
11 #include <limits.h>
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <string.h>
16 #include "windef.h"
17 #include "winnls.h"
18 #include "winbase.h"
19 #include "wingdi.h"
20 #include "winuser.h"
21 #include "windowsx.h"
22 #include "wine/winuser16.h"
23 #include "wine/winbase16.h"
24 #include "wine/unicode.h"
25 #include "controls.h"
26 #include "heap.h"
27 #include "win.h"
28 #include "user.h"
29 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(dialog);
34 /* Dialog control information */
35 typedef struct
37 DWORD style;
38 DWORD exStyle;
39 DWORD helpId;
40 INT16 x;
41 INT16 y;
42 INT16 cx;
43 INT16 cy;
44 UINT id;
45 LPCSTR className;
46 LPCSTR windowName;
47 LPVOID data;
48 } DLG_CONTROL_INFO;
50 /* Dialog template */
51 typedef struct
53 DWORD style;
54 DWORD exStyle;
55 DWORD helpId;
56 UINT16 nbItems;
57 INT16 x;
58 INT16 y;
59 INT16 cx;
60 INT16 cy;
61 LPCSTR menuName;
62 LPCSTR className;
63 LPCSTR caption;
64 WORD pointSize;
65 WORD weight;
66 BOOL italic;
67 LPCSTR faceName;
68 BOOL dialogEx;
69 } DLG_TEMPLATE;
71 /* Radio button group */
72 typedef struct
74 UINT firstID;
75 UINT lastID;
76 UINT checkID;
77 } RADIOGROUP;
79 /* Dialog base units */
80 static WORD xBaseUnit = 0, yBaseUnit = 0;
83 /*********************************************************************
84 * dialog class descriptor
86 const struct builtin_class_descr DIALOG_builtin_class =
88 DIALOG_CLASS_ATOM, /* name */
89 CS_GLOBALCLASS | CS_SAVEBITS, /* style */
90 DefDlgProcA, /* procA */
91 DefDlgProcW, /* procW */
92 DLGWINDOWEXTRA, /* extra */
93 IDC_ARROWA, /* cursor */
94 0 /* brush */
98 /***********************************************************************
99 * DIALOG_EnableOwner
101 * Helper function for modal dialogs to enable again the
102 * owner of the dialog box.
104 void DIALOG_EnableOwner( HWND hOwner )
106 /* Owner must be a top-level window */
107 if (hOwner)
108 hOwner = GetAncestor( hOwner, GA_ROOT );
109 if (!hOwner) return;
110 EnableWindow( hOwner, TRUE );
114 /***********************************************************************
115 * DIALOG_DisableOwner
117 * Helper function for modal dialogs to disable the
118 * owner of the dialog box. Returns TRUE if owner was enabled.
120 BOOL DIALOG_DisableOwner( HWND hOwner )
122 /* Owner must be a top-level window */
123 if (hOwner)
124 hOwner = GetAncestor( hOwner, GA_ROOT );
125 if (!hOwner) return FALSE;
126 if (IsWindowEnabled( hOwner ))
128 EnableWindow( hOwner, FALSE );
129 return TRUE;
131 else
132 return FALSE;
135 /***********************************************************************
136 * DIALOG_GetCharSizeFromDC
139 * Calculates the *true* average size of English characters in the
140 * specified font as oppposed to the one returned by GetTextMetrics.
142 * Latest: the X font driver will now compute a proper average width
143 * so this code can be removed
145 static BOOL DIALOG_GetCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize )
147 BOOL Success = FALSE;
148 HFONT hFontPrev = 0;
149 pSize->cx = xBaseUnit;
150 pSize->cy = yBaseUnit;
151 if ( hDC )
153 /* select the font */
154 TEXTMETRICA tm;
155 memset(&tm,0,sizeof(tm));
156 if (hFont) hFontPrev = SelectFont(hDC,hFont);
157 if (GetTextMetricsA(hDC,&tm))
159 pSize->cx = tm.tmAveCharWidth;
160 pSize->cy = tm.tmHeight;
162 /* if variable width font */
163 if (tm.tmPitchAndFamily & TMPF_FIXED_PITCH)
165 SIZE total;
166 const char* szAvgChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
168 /* Calculate a true average as opposed to the one returned
169 * by tmAveCharWidth. This works better when dealing with
170 * proportional spaced fonts and (more important) that's
171 * how Microsoft's dialog creation code calculates the size
172 * of the font
174 if (GetTextExtentPointA(hDC,szAvgChars,sizeof(szAvgChars),&total))
176 /* round up */
177 pSize->cx = ((2*total.cx/sizeof(szAvgChars)) + 1)/2;
178 Success = TRUE;
181 else
183 Success = TRUE;
185 /* Use the text metrics */
186 TRACE("Using tm: %ldx%ld (dlg: %ld x %ld) (%s)\n",
187 tm.tmAveCharWidth, tm.tmHeight, pSize->cx, pSize->cy,
188 tm.tmPitchAndFamily & TMPF_FIXED_PITCH ? "variable" : "fixed");
189 pSize->cx = tm.tmAveCharWidth;
190 pSize->cy = tm.tmHeight;
192 /* select the original font */
193 if (hFontPrev) SelectFont(hDC,hFontPrev);
195 return (Success);
198 /***********************************************************************
199 * DIALOG_GetCharSize
201 * A convenient variant of DIALOG_GetCharSizeFromDC.
203 static BOOL DIALOG_GetCharSize( HFONT hFont, SIZE * pSize )
205 HDC hDC = GetDC(0);
206 BOOL Success = DIALOG_GetCharSizeFromDC( hDC, hFont, pSize );
207 ReleaseDC(0, hDC);
208 return Success;
211 /***********************************************************************
212 * DIALOG_Init
214 * Initialisation of the dialog manager.
216 BOOL DIALOG_Init(void)
218 HDC hdc;
219 SIZE size;
221 /* Calculate the dialog base units */
223 if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL )))
225 ERR("Could not create Display DC\n");
226 return FALSE;
229 if (!DIALOG_GetCharSizeFromDC( hdc, 0, &size ))
231 DeleteDC( hdc );
232 ERR("Could not initialize base dialog units\n");
233 return FALSE;
236 DeleteDC( hdc );
237 xBaseUnit = size.cx;
238 yBaseUnit = size.cy;
240 TRACE("base units = %d,%d\n", xBaseUnit, yBaseUnit );
241 return TRUE;
245 /***********************************************************************
246 * DIALOG_GetControl16
248 * Return the class and text of the control pointed to by ptr,
249 * fill the header structure and return a pointer to the next control.
251 static LPCSTR DIALOG_GetControl16( LPCSTR p, DLG_CONTROL_INFO *info )
253 static char buffer[10];
254 int int_id;
256 info->x = GET_WORD(p); p += sizeof(WORD);
257 info->y = GET_WORD(p); p += sizeof(WORD);
258 info->cx = GET_WORD(p); p += sizeof(WORD);
259 info->cy = GET_WORD(p); p += sizeof(WORD);
260 info->id = GET_WORD(p); p += sizeof(WORD);
261 info->style = GET_DWORD(p); p += sizeof(DWORD);
262 info->exStyle = 0;
264 if (*p & 0x80)
266 switch((BYTE)*p)
268 case 0x80: strcpy( buffer, "BUTTON" ); break;
269 case 0x81: strcpy( buffer, "EDIT" ); break;
270 case 0x82: strcpy( buffer, "STATIC" ); break;
271 case 0x83: strcpy( buffer, "LISTBOX" ); break;
272 case 0x84: strcpy( buffer, "SCROLLBAR" ); break;
273 case 0x85: strcpy( buffer, "COMBOBOX" ); break;
274 default: buffer[0] = '\0'; break;
276 info->className = buffer;
277 p++;
279 else
281 info->className = p;
282 p += strlen(p) + 1;
285 int_id = ((BYTE)*p == 0xff);
286 if (int_id)
288 /* Integer id, not documented (?). Only works for SS_ICON controls */
289 info->windowName = (LPCSTR)(UINT)GET_WORD(p+1);
290 p += 3;
292 else
294 info->windowName = p;
295 p += strlen(p) + 1;
298 if (*p)
300 /* Additional CTLDATA available for this control. */
301 info->data = SEGPTR_ALLOC(*p);
302 memcpy( info->data, p + 1, *p );
304 else info->data = NULL;
306 p += *p + 1;
308 if(int_id)
309 TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %08lx\n",
310 info->className, LOWORD(info->windowName),
311 info->id, info->x, info->y, info->cx, info->cy,
312 info->style, (DWORD)SEGPTR_GET(info->data) );
313 else
314 TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %08lx\n",
315 info->className, info->windowName,
316 info->id, info->x, info->y, info->cx, info->cy,
317 info->style, (DWORD)SEGPTR_GET(info->data) );
319 return p;
323 /***********************************************************************
324 * DIALOG_GetControl32
326 * Return the class and text of the control pointed to by ptr,
327 * fill the header structure and return a pointer to the next control.
329 static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
330 BOOL dialogEx )
332 if (dialogEx)
334 info->helpId = GET_DWORD(p); p += 2;
335 info->exStyle = GET_DWORD(p); p += 2;
336 info->style = GET_DWORD(p); p += 2;
338 else
340 info->helpId = 0;
341 info->style = GET_DWORD(p); p += 2;
342 info->exStyle = GET_DWORD(p); p += 2;
344 info->x = GET_WORD(p); p++;
345 info->y = GET_WORD(p); p++;
346 info->cx = GET_WORD(p); p++;
347 info->cy = GET_WORD(p); p++;
349 if (dialogEx)
351 /* id is a DWORD for DIALOGEX */
352 info->id = GET_DWORD(p);
353 p += 2;
355 else
357 info->id = GET_WORD(p);
358 p++;
361 if (GET_WORD(p) == 0xffff)
363 static const WCHAR class_names[6][10] =
365 { 'B','u','t','t','o','n', }, /* 0x80 */
366 { 'E','d','i','t', }, /* 0x81 */
367 { 'S','t','a','t','i','c', }, /* 0x82 */
368 { 'L','i','s','t','B','o','x', }, /* 0x83 */
369 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
370 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
372 WORD id = GET_WORD(p+1);
373 if ((id >= 0x80) && (id <= 0x85))
374 info->className = (LPCSTR)class_names[id - 0x80];
375 else
377 info->className = NULL;
378 ERR("Unknown built-in class id %04x\n", id );
380 p += 2;
382 else
384 info->className = (LPCSTR)p;
385 p += strlenW( (LPCWSTR)p ) + 1;
388 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
390 info->windowName = (LPCSTR)(UINT)GET_WORD(p + 1);
391 p += 2;
393 else
395 info->windowName = (LPCSTR)p;
396 p += strlenW( (LPCWSTR)p ) + 1;
399 TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
400 debugstr_w( (LPCWSTR)info->className ),
401 debugres_w( (LPCWSTR)info->windowName ),
402 info->id, info->x, info->y, info->cx, info->cy,
403 info->style, info->exStyle, info->helpId );
405 if (GET_WORD(p))
407 if (TRACE_ON(dialog))
409 WORD i, count = GET_WORD(p) / sizeof(WORD);
410 TRACE(" BEGIN\n");
411 TRACE(" ");
412 for (i = 0; i < count; i++) DPRINTF( "%04x,", GET_WORD(p+i+1) );
413 DPRINTF("\n");
414 TRACE(" END\n" );
416 info->data = (LPVOID)(p + 1);
417 p += GET_WORD(p) / sizeof(WORD);
419 else info->data = NULL;
420 p++;
422 /* Next control is on dword boundary */
423 return (const WORD *)((((int)p) + 3) & ~3);
427 /***********************************************************************
428 * DIALOG_CreateControls
430 * Create the control windows for a dialog.
432 static BOOL DIALOG_CreateControls( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate,
433 HINSTANCE hInst, BOOL win32 )
435 DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd );
436 DLG_CONTROL_INFO info;
437 HWND hwndCtrl, hwndDefButton = 0;
438 INT items = dlgTemplate->nbItems;
440 TRACE(" BEGIN\n" );
441 while (items--)
443 if (!win32)
445 HINSTANCE16 instance;
446 template = DIALOG_GetControl16( template, &info );
447 if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
448 !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT))
450 if (!dlgInfo->hDialogHeap)
452 dlgInfo->hDialogHeap = GlobalAlloc16(GMEM_FIXED, 0x10000);
453 if (!dlgInfo->hDialogHeap)
455 ERR("Insufficient memory to create heap for edit control\n" );
456 continue;
458 LocalInit16(dlgInfo->hDialogHeap, 0, 0xffff);
460 instance = dlgInfo->hDialogHeap;
462 else instance = (HINSTANCE16)hInst;
464 hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
465 info.className, info.windowName,
466 info.style | WS_CHILD,
467 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
468 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
469 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
470 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
471 WIN_Handle16(hwnd), (HMENU16)info.id,
472 instance, (LPVOID)SEGPTR_GET(info.data) ));
474 if (info.data) SEGPTR_FREE(info.data);
476 else
478 template = (LPCSTR)DIALOG_GetControl32( (WORD *)template, &info,
479 dlgTemplate->dialogEx );
480 /* Is this it? */
481 if (info.style & WS_BORDER)
483 info.style &= ~WS_BORDER;
484 info.exStyle |= WS_EX_CLIENTEDGE;
486 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY,
487 (LPCWSTR)info.className,
488 (LPCWSTR)info.windowName,
489 info.style | WS_CHILD,
490 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
491 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
492 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
493 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
494 hwnd, (HMENU)info.id,
495 hInst, info.data );
497 if (!hwndCtrl) return FALSE;
499 /* Send initialisation messages to the control */
500 if (dlgInfo->hUserFont) SendMessageA( hwndCtrl, WM_SETFONT,
501 (WPARAM)dlgInfo->hUserFont, 0 );
502 if (SendMessageA(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
504 /* If there's already a default push-button, set it back */
505 /* to normal and use this one instead. */
506 if (hwndDefButton)
507 SendMessageA( hwndDefButton, BM_SETSTYLE,
508 BS_PUSHBUTTON,FALSE );
509 hwndDefButton = hwndCtrl;
510 dlgInfo->idResult = GetWindowLongA( hwndCtrl, GWL_ID );
513 TRACE(" END\n" );
514 return TRUE;
518 /***********************************************************************
519 * DIALOG_ParseTemplate16
521 * Fill a DLG_TEMPLATE structure from the dialog template, and return
522 * a pointer to the first control.
524 static LPCSTR DIALOG_ParseTemplate16( LPCSTR p, DLG_TEMPLATE * result )
526 result->style = GET_DWORD(p); p += sizeof(DWORD);
527 result->exStyle = 0;
528 result->nbItems = (unsigned char) *p++;
529 result->x = GET_WORD(p); p += sizeof(WORD);
530 result->y = GET_WORD(p); p += sizeof(WORD);
531 result->cx = GET_WORD(p); p += sizeof(WORD);
532 result->cy = GET_WORD(p); p += sizeof(WORD);
533 TRACE("DIALOG %d, %d, %d, %d\n",
534 result->x, result->y, result->cx, result->cy );
535 TRACE(" STYLE %08lx\n", result->style );
537 /* Get the menu name */
539 switch( (BYTE)*p )
541 case 0:
542 result->menuName = 0;
543 p++;
544 break;
545 case 0xff:
546 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
547 p += 3;
548 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
549 break;
550 default:
551 result->menuName = p;
552 TRACE(" MENU '%s'\n", p );
553 p += strlen(p) + 1;
554 break;
557 /* Get the class name */
559 if (*p)
561 result->className = p;
562 TRACE(" CLASS '%s'\n", result->className );
564 else result->className = DIALOG_CLASS_ATOM;
565 p += strlen(p) + 1;
567 /* Get the window caption */
569 result->caption = p;
570 p += strlen(p) + 1;
571 TRACE(" CAPTION '%s'\n", result->caption );
573 /* Get the font name */
575 if (result->style & DS_SETFONT)
577 result->pointSize = GET_WORD(p);
578 p += sizeof(WORD);
579 result->faceName = p;
580 p += strlen(p) + 1;
581 TRACE(" FONT %d,'%s'\n",
582 result->pointSize, result->faceName );
584 return p;
588 /***********************************************************************
589 * DIALOG_ParseTemplate32
591 * Fill a DLG_TEMPLATE structure from the dialog template, and return
592 * a pointer to the first control.
594 static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
596 const WORD *p = (const WORD *)template;
598 result->style = GET_DWORD(p); p += 2;
599 if (result->style == 0xffff0001) /* DIALOGEX resource */
601 result->dialogEx = TRUE;
602 result->helpId = GET_DWORD(p); p += 2;
603 result->exStyle = GET_DWORD(p); p += 2;
604 result->style = GET_DWORD(p); p += 2;
606 else
608 result->dialogEx = FALSE;
609 result->helpId = 0;
610 result->exStyle = GET_DWORD(p); p += 2;
612 result->nbItems = GET_WORD(p); p++;
613 result->x = GET_WORD(p); p++;
614 result->y = GET_WORD(p); p++;
615 result->cx = GET_WORD(p); p++;
616 result->cy = GET_WORD(p); p++;
617 TRACE("DIALOG%s %d, %d, %d, %d, %ld\n",
618 result->dialogEx ? "EX" : "", result->x, result->y,
619 result->cx, result->cy, result->helpId );
620 TRACE(" STYLE 0x%08lx\n", result->style );
621 TRACE(" EXSTYLE 0x%08lx\n", result->exStyle );
623 /* Get the menu name */
625 switch(GET_WORD(p))
627 case 0x0000:
628 result->menuName = NULL;
629 p++;
630 break;
631 case 0xffff:
632 result->menuName = (LPCSTR)(UINT)GET_WORD( p + 1 );
633 p += 2;
634 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
635 break;
636 default:
637 result->menuName = (LPCSTR)p;
638 TRACE(" MENU %s\n", debugstr_w( (LPCWSTR)p ));
639 p += strlenW( (LPCWSTR)p ) + 1;
640 break;
643 /* Get the class name */
645 switch(GET_WORD(p))
647 case 0x0000:
648 result->className = DIALOG_CLASS_ATOM;
649 p++;
650 break;
651 case 0xffff:
652 result->className = (LPCSTR)(UINT)GET_WORD( p + 1 );
653 p += 2;
654 TRACE(" CLASS %04x\n", LOWORD(result->className) );
655 break;
656 default:
657 result->className = (LPCSTR)p;
658 TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR)p ));
659 p += strlenW( (LPCWSTR)p ) + 1;
660 break;
663 /* Get the window caption */
665 result->caption = (LPCSTR)p;
666 p += strlenW( (LPCWSTR)p ) + 1;
667 TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR)result->caption ) );
669 /* Get the font name */
671 if (result->style & DS_SETFONT)
673 result->pointSize = GET_WORD(p);
674 p++;
675 if (result->dialogEx)
677 result->weight = GET_WORD(p); p++;
678 result->italic = LOBYTE(GET_WORD(p)); p++;
680 else
682 result->weight = FW_DONTCARE;
683 result->italic = FALSE;
685 result->faceName = (LPCSTR)p;
686 p += strlenW( (LPCWSTR)p ) + 1;
687 TRACE(" FONT %d, %s, %d, %s\n",
688 result->pointSize, debugstr_w( (LPCWSTR)result->faceName ),
689 result->weight, result->italic ? "TRUE" : "FALSE" );
692 /* First control is on dword boundary */
693 return (LPCSTR)((((int)p) + 3) & ~3);
697 /***********************************************************************
698 * DIALOG_CreateIndirect
699 * Creates a dialog box window
701 * modal = TRUE if we are called from a modal dialog box.
702 * (it's more compatible to do it here, as under Windows the owner
703 * is never disabled if the dialog fails because of an invalid template)
705 static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCSTR dlgTemplate,
706 HWND owner, DLGPROC dlgProc, LPARAM param,
707 WINDOWPROCTYPE procType, BOOL modal )
709 HWND hwnd;
710 RECT rect;
711 WND * wndPtr;
712 DLG_TEMPLATE template;
713 DIALOGINFO * dlgInfo;
714 BOOL ownerEnabled = TRUE;
715 BOOL win32Template = (procType != WIN_PROC_16);
717 /* Parse dialog template */
719 if (!dlgTemplate) return 0;
720 if (win32Template)
721 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
722 else
723 dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
725 /* Initialise dialog extra data */
727 if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) return 0;
728 dlgInfo->hwndFocus = 0;
729 dlgInfo->hUserFont = 0;
730 dlgInfo->hMenu = 0;
731 dlgInfo->xBaseUnit = xBaseUnit;
732 dlgInfo->yBaseUnit = yBaseUnit;
733 dlgInfo->idResult = 0;
734 dlgInfo->flags = 0;
735 dlgInfo->hDialogHeap = 0;
737 /* Load menu */
739 if (template.menuName)
741 if (!win32Template) dlgInfo->hMenu = LoadMenu16( hInst, template.menuName );
742 else dlgInfo->hMenu = LoadMenuW( hInst, (LPCWSTR)template.menuName );
745 /* Create custom font if needed */
747 if (template.style & DS_SETFONT)
749 /* The font height must be negative as it is a point size */
750 /* and must be converted to pixels first */
751 /* (see CreateFont() documentation in the Windows SDK). */
752 HDC dc;
753 int pixels;
754 if (((short)template.pointSize) < 0)
755 pixels = -((short)template.pointSize);
756 else
758 dc = GetDC(0);
759 pixels = template.pointSize * GetDeviceCaps(dc , LOGPIXELSY)/72;
760 ReleaseDC(0, dc);
762 if (win32Template)
763 dlgInfo->hUserFont = CreateFontW( -pixels, 0, 0, 0, template.weight,
764 template.italic, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
765 PROOF_QUALITY, FF_DONTCARE,
766 (LPCWSTR)template.faceName );
767 else
768 dlgInfo->hUserFont = CreateFontA( -pixels, 0, 0, 0, FW_DONTCARE,
769 FALSE, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
770 PROOF_QUALITY, FF_DONTCARE, template.faceName );
771 if (dlgInfo->hUserFont)
773 SIZE charSize;
774 if (DIALOG_GetCharSize( dlgInfo->hUserFont, &charSize ))
776 dlgInfo->xBaseUnit = charSize.cx;
777 dlgInfo->yBaseUnit = charSize.cy;
780 TRACE("units = %d,%d\n", dlgInfo->xBaseUnit, dlgInfo->yBaseUnit );
783 /* Create dialog main window */
785 rect.left = rect.top = 0;
786 rect.right = MulDiv(template.cx, dlgInfo->xBaseUnit, 4);
787 rect.bottom = MulDiv(template.cy, dlgInfo->yBaseUnit, 8);
788 if (template.style & DS_MODALFRAME)
789 template.exStyle |= WS_EX_DLGMODALFRAME;
790 AdjustWindowRectEx( &rect, template.style, (dlgInfo->hMenu != 0), template.exStyle );
791 rect.right -= rect.left;
792 rect.bottom -= rect.top;
794 if ((INT16)template.x == CW_USEDEFAULT16)
796 rect.left = rect.top = win32Template? CW_USEDEFAULT : CW_USEDEFAULT16;
798 else
800 if (template.style & DS_CENTER)
802 rect.left = (GetSystemMetrics(SM_CXSCREEN) - rect.right) / 2;
803 rect.top = (GetSystemMetrics(SM_CYSCREEN) - rect.bottom) / 2;
805 else
807 rect.left += MulDiv(template.x, dlgInfo->xBaseUnit, 4);
808 rect.top += MulDiv(template.y, dlgInfo->yBaseUnit, 8);
810 if ( !(template.style & WS_CHILD) )
812 INT16 dX, dY;
814 if( !(template.style & DS_ABSALIGN) )
815 ClientToScreen( owner, (POINT *)&rect );
817 /* try to fit it into the desktop */
819 if( (dX = rect.left + rect.right + GetSystemMetrics(SM_CXDLGFRAME)
820 - GetSystemMetrics(SM_CXSCREEN)) > 0 ) rect.left -= dX;
821 if( (dY = rect.top + rect.bottom + GetSystemMetrics(SM_CYDLGFRAME)
822 - GetSystemMetrics(SM_CYSCREEN)) > 0 ) rect.top -= dY;
823 if( rect.left < 0 ) rect.left = 0;
824 if( rect.top < 0 ) rect.top = 0;
828 if (modal)
830 ownerEnabled = DIALOG_DisableOwner( owner );
831 if (ownerEnabled) dlgInfo->flags |= DF_OWNERENABLED;
834 if (!win32Template)
835 hwnd = WIN_Handle32( CreateWindowEx16(template.exStyle, template.className,
836 template.caption, template.style & ~WS_VISIBLE,
837 rect.left, rect.top, rect.right, rect.bottom,
838 WIN_Handle16(owner), dlgInfo->hMenu, hInst, NULL ));
839 else
840 hwnd = CreateWindowExW(template.exStyle, (LPCWSTR)template.className,
841 (LPCWSTR)template.caption,
842 template.style & ~WS_VISIBLE,
843 rect.left, rect.top, rect.right, rect.bottom,
844 owner, dlgInfo->hMenu, hInst, NULL );
846 if (!hwnd)
848 if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
849 if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );
850 if (modal && (dlgInfo->flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
851 HeapFree( GetProcessHeap(), 0, dlgInfo );
852 return 0;
854 wndPtr = WIN_GetPtr( hwnd );
855 wndPtr->flags |= WIN_ISDIALOG;
856 WIN_ReleasePtr( wndPtr );
858 if (template.helpId) SetWindowContextHelpId( hwnd, template.helpId );
859 SetWindowLongW( hwnd, DWL_WINE_DIALOGINFO, (LONG)dlgInfo );
860 switch(procType)
862 case WIN_PROC_16: SetWindowLong16( WIN_Handle16(hwnd), DWL_DLGPROC, (LONG)dlgProc ); break;
863 case WIN_PROC_32A: SetWindowLongA( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
864 case WIN_PROC_32W: SetWindowLongW( hwnd, DWL_DLGPROC, (LONG)dlgProc ); break;
865 default: break;
868 if (dlgInfo->hUserFont)
869 SendMessageA( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
871 /* Create controls */
873 if (DIALOG_CreateControls( hwnd, dlgTemplate, &template,
874 hInst, win32Template ))
876 HWND hwndPreInitFocus;
878 /* Send initialisation messages and set focus */
880 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE );
882 hwndPreInitFocus = GetFocus();
883 if (SendMessageA( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ))
885 /* check where the focus is again,
886 * some controls status might have changed in WM_INITDIALOG */
887 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
888 SetFocus( dlgInfo->hwndFocus );
890 else
892 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
893 but the focus has not changed, set the focus where we expect it. */
894 if ((GetFocus() == hwndPreInitFocus) &&
895 (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
897 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
898 SetFocus( dlgInfo->hwndFocus );
902 if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
904 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
906 return hwnd;
908 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
909 if (modal && ownerEnabled) DIALOG_EnableOwner(owner);
910 return 0;
914 /***********************************************************************
915 * CreateDialog (USER.89)
917 HWND16 WINAPI CreateDialog16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
918 HWND16 owner, DLGPROC16 dlgProc )
920 return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
924 /***********************************************************************
925 * CreateDialogParam (USER.241)
927 HWND16 WINAPI CreateDialogParam16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
928 HWND16 owner, DLGPROC16 dlgProc,
929 LPARAM param )
931 HWND16 hwnd = 0;
932 HRSRC16 hRsrc;
933 HGLOBAL16 hmem;
934 LPCVOID data;
936 TRACE("%04x,%s,%04x,%08lx,%ld\n",
937 hInst, debugres_a(dlgTemplate), owner, (DWORD)dlgProc, param );
939 if (!(hRsrc = FindResource16( hInst, dlgTemplate, RT_DIALOGA ))) return 0;
940 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
941 if (!(data = LockResource16( hmem ))) hwnd = 0;
942 else hwnd = CreateDialogIndirectParam16( hInst, data, owner,
943 dlgProc, param );
944 FreeResource16( hmem );
945 return hwnd;
948 /***********************************************************************
949 * CreateDialogParamA (USER32.@)
951 HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name,
952 HWND owner, DLGPROC dlgProc,
953 LPARAM param )
955 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
956 if (!hrsrc) return 0;
957 return CreateDialogIndirectParamA( hInst,
958 (LPVOID)LoadResource(hInst, hrsrc),
959 owner, dlgProc, param );
963 /***********************************************************************
964 * CreateDialogParamW (USER32.@)
966 HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name,
967 HWND owner, DLGPROC dlgProc,
968 LPARAM param )
970 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
971 if (!hrsrc) return 0;
972 return CreateDialogIndirectParamW( hInst,
973 (LPVOID)LoadResource(hInst, hrsrc),
974 owner, dlgProc, param );
978 /***********************************************************************
979 * CreateDialogIndirect (USER.219)
981 HWND16 WINAPI CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
982 HWND16 owner, DLGPROC16 dlgProc )
984 return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
988 /***********************************************************************
989 * CreateDialogIndirectParam (USER.242)
990 * CreateDialogIndirectParam16 (USER32.@)
992 HWND16 WINAPI CreateDialogIndirectParam16( HINSTANCE16 hInst,
993 LPCVOID dlgTemplate,
994 HWND16 owner, DLGPROC16 dlgProc,
995 LPARAM param )
997 return WIN_Handle16( DIALOG_CreateIndirect( hInst, dlgTemplate, WIN_Handle32(owner),
998 (DLGPROC)dlgProc, param, WIN_PROC_16, FALSE ));
1002 /***********************************************************************
1003 * CreateDialogIndirectParamA (USER32.@)
1005 HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst,
1006 LPCVOID dlgTemplate,
1007 HWND owner, DLGPROC dlgProc,
1008 LPARAM param )
1010 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32A, FALSE );
1013 /***********************************************************************
1014 * CreateDialogIndirectParamAorW (USER32.@)
1016 HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst,
1017 LPCVOID dlgTemplate,
1018 HWND owner, DLGPROC dlgProc,
1019 LPARAM param )
1020 { FIXME("assume WIN_PROC_32W\n");
1021 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
1024 /***********************************************************************
1025 * CreateDialogIndirectParamW (USER32.@)
1027 HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst,
1028 LPCVOID dlgTemplate,
1029 HWND owner, DLGPROC dlgProc,
1030 LPARAM param )
1032 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, WIN_PROC_32W, FALSE );
1036 /***********************************************************************
1037 * DIALOG_DoDialogBox
1039 static INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
1041 DIALOGINFO * dlgInfo;
1042 MSG msg;
1043 INT retval;
1044 HWND ownerMsg = GetAncestor( owner, GA_ROOT );
1046 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return -1;
1048 if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
1050 ShowWindow( hwnd, SW_SHOW );
1051 for (;;)
1053 if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG))
1055 if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
1057 /* No message present -> send ENTERIDLE and wait */
1058 SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd );
1059 if (!GetMessageW( &msg, 0, 0, 0 )) break;
1062 else if (!GetMessageW( &msg, 0, 0, 0 )) break;
1064 if (CallMsgFilterW( &msg, MSGF_DIALOGBOX )) continue;
1066 if (!IsWindow( hwnd )) return -1;
1067 if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))
1069 TranslateMessage( &msg );
1070 DispatchMessageW( &msg );
1072 if (dlgInfo->flags & DF_END) break;
1075 if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner );
1076 retval = dlgInfo->idResult;
1077 DestroyWindow( hwnd );
1078 return retval;
1082 /***********************************************************************
1083 * DialogBox (USER.87)
1085 INT16 WINAPI DialogBox16( HINSTANCE16 hInst, LPCSTR dlgTemplate,
1086 HWND16 owner, DLGPROC16 dlgProc )
1088 return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1092 /***********************************************************************
1093 * DialogBoxParam (USER.239)
1095 INT16 WINAPI DialogBoxParam16( HINSTANCE16 hInst, LPCSTR template,
1096 HWND16 owner16, DLGPROC16 dlgProc, LPARAM param )
1098 HWND hwnd = 0;
1099 HRSRC16 hRsrc;
1100 HGLOBAL16 hmem;
1101 LPCVOID data;
1102 int ret = -1;
1104 if (!(hRsrc = FindResource16( hInst, template, RT_DIALOGA ))) return 0;
1105 if (!(hmem = LoadResource16( hInst, hRsrc ))) return 0;
1106 if ((data = LockResource16( hmem )))
1108 HWND owner = WIN_Handle32(owner16);
1109 hwnd = DIALOG_CreateIndirect( hInst, data, owner,
1110 (DLGPROC)dlgProc, param, WIN_PROC_16, TRUE );
1111 if (hwnd) ret = DIALOG_DoDialogBox( hwnd, owner );
1112 GlobalUnlock16( hmem );
1114 FreeResource16( hmem );
1115 return ret;
1119 /***********************************************************************
1120 * DialogBoxParamA (USER32.@)
1122 INT WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
1123 HWND owner, DLGPROC dlgProc, LPARAM param )
1125 HWND hwnd;
1126 HANDLE hrsrc = FindResourceA( hInst, name, RT_DIALOGA );
1127 if (!hrsrc) return 0;
1128 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1129 owner, dlgProc, param, WIN_PROC_32A, TRUE );
1130 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1131 return -1;
1135 /***********************************************************************
1136 * DialogBoxParamW (USER32.@)
1138 INT WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
1139 HWND owner, DLGPROC dlgProc, LPARAM param )
1141 HWND hwnd;
1142 HANDLE hrsrc = FindResourceW( hInst, name, RT_DIALOGW );
1143 if (!hrsrc) return 0;
1144 hwnd = DIALOG_CreateIndirect( hInst, (LPVOID)LoadResource(hInst, hrsrc),
1145 owner, dlgProc, param, WIN_PROC_32W, TRUE );
1146 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1147 return -1;
1151 /***********************************************************************
1152 * DialogBoxIndirect (USER.218)
1154 INT16 WINAPI DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1155 HWND16 owner, DLGPROC16 dlgProc )
1157 return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
1161 /***********************************************************************
1162 * DialogBoxIndirectParam (USER.240)
1163 * DialogBoxIndirectParam16 (USER32.@)
1165 INT16 WINAPI DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
1166 HWND16 owner16, DLGPROC16 dlgProc,
1167 LPARAM param )
1169 HWND hwnd, owner = WIN_Handle32( owner16 );
1170 LPCVOID ptr;
1172 if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
1173 hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, (DLGPROC)dlgProc,
1174 param, WIN_PROC_16, TRUE );
1175 GlobalUnlock16( dlgTemplate );
1176 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1177 return -1;
1181 /***********************************************************************
1182 * DialogBoxIndirectParamA (USER32.@)
1184 INT WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCVOID template,
1185 HWND owner, DLGPROC dlgProc,
1186 LPARAM param )
1188 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1189 dlgProc, param, WIN_PROC_32A, TRUE );
1190 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1191 return -1;
1195 /***********************************************************************
1196 * DialogBoxIndirectParamW (USER32.@)
1198 INT WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCVOID template,
1199 HWND owner, DLGPROC dlgProc,
1200 LPARAM param )
1202 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner,
1203 dlgProc, param, WIN_PROC_32W, TRUE );
1204 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1205 return -1;
1208 /***********************************************************************
1209 * DialogBoxIndirectParamAorW (USER32.@)
1211 INT WINAPI DialogBoxIndirectParamAorW(HINSTANCE hInstance, LPCVOID template,
1212 HWND owner, DLGPROC dlgProc,
1213 LPARAM param, DWORD x )
1215 HWND hwnd;
1216 FIXME("0x%08x %p 0x%08x %p 0x%08lx 0x%08lx\n",
1217 hInstance, template, owner, dlgProc, param, x);
1218 hwnd = DIALOG_CreateIndirect( hInstance, template, owner, dlgProc, param, WIN_PROC_32W, TRUE );
1219 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
1220 return -1;
1223 /***********************************************************************
1224 * EndDialog (USER32.@)
1226 BOOL WINAPI EndDialog( HWND hwnd, INT retval )
1228 BOOL wasEnabled = TRUE;
1229 DIALOGINFO * dlgInfo;
1230 HWND owner;
1232 TRACE("%04x %d\n", hwnd, retval );
1234 if (!(dlgInfo = DIALOG_get_info( hwnd )))
1236 ERR("got invalid window handle (%04x); buggy app !?\n", hwnd);
1237 return FALSE;
1239 dlgInfo->idResult = retval;
1240 dlgInfo->flags |= DF_END;
1241 wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
1243 if (wasEnabled && (owner = GetWindow( hwnd, GW_OWNER )))
1244 DIALOG_EnableOwner( owner );
1246 /* Windows sets the focus to the dialog itself in EndDialog */
1248 if (IsChild(hwnd, GetFocus()))
1249 SetFocus( hwnd );
1251 /* Don't have to send a ShowWindow(SW_HIDE), just do
1252 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1254 SetWindowPos(hwnd, (HWND)0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
1255 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
1257 /* unblock dialog loop */
1258 PostMessageA(hwnd, WM_NULL, 0, 0);
1259 return TRUE;
1263 /***********************************************************************
1264 * DIALOG_IsAccelerator
1266 static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM vKey )
1268 HWND hwndControl = hwnd;
1269 HWND hwndNext;
1270 INT dlgCode;
1271 WCHAR buffer[128];
1275 DWORD style = GetWindowLongW( hwndControl, GWL_STYLE );
1276 if ((style & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE)
1278 dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
1279 if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
1280 GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) ))
1282 /* find the accelerator key */
1283 LPWSTR p = buffer - 2;
1284 char a_char = vKey;
1285 WCHAR w_char = 0;
1289 p = strchrW( p + 2, '&' );
1291 while (p != NULL && p[1] == '&');
1293 /* and check if it's the one we're looking for */
1294 MultiByteToWideChar(CP_ACP, 0, &a_char, 1, &w_char, 1);
1295 if (p != NULL && toupperW( p[1] ) == toupperW( w_char ) )
1297 if ((dlgCode & DLGC_STATIC) || (style & 0x0f) == BS_GROUPBOX )
1299 /* set focus to the control */
1300 SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, 1);
1301 /* and bump it on to next */
1302 SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
1304 else if (dlgCode & DLGC_BUTTON)
1306 /* send BM_CLICK message to the control */
1307 SendMessageA( hwndControl, BM_CLICK, 0, 0 );
1309 return TRUE;
1312 hwndNext = GetWindow( hwndControl, GW_CHILD );
1314 else hwndNext = 0;
1316 if (!hwndNext) hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1318 while (!hwndNext && hwndControl)
1320 hwndControl = GetParent( hwndControl );
1321 if (hwndControl == hwndDlg)
1323 if(hwnd==hwndDlg) /* prevent endless loop */
1325 hwndNext=hwnd;
1326 break;
1328 hwndNext = GetWindow( hwndDlg, GW_CHILD );
1330 else
1331 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1333 hwndControl = hwndNext;
1335 while (hwndControl && (hwndControl != hwnd));
1337 return FALSE;
1340 /***********************************************************************
1341 * DIALOG_FindMsgDestination
1343 * The messages that IsDialogMessage sends may not go to the dialog
1344 * calling IsDialogMessage if that dialog is a child, and it has the
1345 * DS_CONTROL style set.
1346 * We propagate up until we hit one that does not have DS_CONTROL, or
1347 * whose parent is not a dialog.
1349 * This is undocumented behaviour.
1351 static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
1353 while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL)
1355 WND *pParent;
1356 HWND hParent = GetParent(hwndDlg);
1357 if (!hParent) break;
1359 pParent = WIN_FindWndPtr(hParent);
1360 if (!pParent) break;
1362 if (!(pParent->flags & WIN_ISDIALOG))
1364 WIN_ReleaseWndPtr(pParent);
1365 break;
1367 WIN_ReleaseWndPtr(pParent);
1369 hwndDlg = hParent;
1372 return hwndDlg;
1375 /***********************************************************************
1376 * DIALOG_IsDialogMessage
1378 static BOOL DIALOG_IsDialogMessage( HWND hwnd, HWND hwndDlg,
1379 UINT message, WPARAM wParam,
1380 LPARAM lParam, BOOL *translate,
1381 BOOL *dispatch, INT dlgCode )
1383 *translate = *dispatch = FALSE;
1385 if (message == WM_PAINT)
1387 /* Apparently, we have to handle this one as well */
1388 *dispatch = TRUE;
1389 return TRUE;
1392 /* Only the key messages get special processing */
1393 if ((message != WM_KEYDOWN) &&
1394 (message != WM_SYSKEYDOWN) &&
1395 (message != WM_SYSCHAR) &&
1396 (message != WM_CHAR))
1397 return FALSE;
1399 if (dlgCode & DLGC_WANTMESSAGE)
1401 *translate = *dispatch = TRUE;
1402 return TRUE;
1405 hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
1407 switch(message)
1409 case WM_KEYDOWN:
1410 switch(wParam)
1412 case VK_TAB:
1413 if (!(dlgCode & DLGC_WANTTAB))
1415 SendMessageA( hwndDlg, WM_NEXTDLGCTL,
1416 (GetKeyState(VK_SHIFT) & 0x8000), 0 );
1417 return TRUE;
1419 break;
1421 case VK_RIGHT:
1422 case VK_DOWN:
1423 case VK_LEFT:
1424 case VK_UP:
1425 if (!(dlgCode & DLGC_WANTARROWS))
1427 BOOL fPrevious = (wParam == VK_LEFT || wParam == VK_UP);
1428 HWND hwndNext =
1429 GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious );
1430 SendMessageA( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndNext, 1 );
1431 return TRUE;
1433 break;
1435 case VK_ESCAPE:
1436 SendMessageA( hwndDlg, WM_COMMAND, IDCANCEL,
1437 (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
1438 return TRUE;
1440 case VK_RETURN:
1442 DWORD dw = SendMessageW( hwndDlg, DM_GETDEFID, 0, 0 );
1443 if (HIWORD(dw) == DC_HASDEFID)
1445 SendMessageA( hwndDlg, WM_COMMAND,
1446 MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
1447 (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw)));
1449 else
1451 SendMessageA( hwndDlg, WM_COMMAND, IDOK,
1452 (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
1456 return TRUE;
1458 *translate = TRUE;
1459 break; /* case WM_KEYDOWN */
1461 case WM_CHAR:
1462 if (dlgCode & DLGC_WANTCHARS) break;
1463 /* drop through */
1465 case WM_SYSCHAR:
1466 if (DIALOG_IsAccelerator( WIN_GetFullHandle(hwnd), hwndDlg, wParam ))
1468 /* don't translate or dispatch */
1469 return TRUE;
1471 break;
1473 case WM_SYSKEYDOWN:
1474 *translate = TRUE;
1475 break;
1478 /* If we get here, the message has not been treated specially */
1479 /* and can be sent to its destination window. */
1480 *dispatch = TRUE;
1481 return TRUE;
1485 /***********************************************************************
1486 * IsDialogMessage (USER.90)
1488 BOOL16 WINAPI IsDialogMessage16( HWND16 hwndDlg, SEGPTR msg16 )
1490 LPMSG16 msg = MapSL(msg16);
1491 BOOL ret, translate, dispatch;
1492 INT dlgCode = 0;
1494 if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
1495 return FALSE;
1497 if ((msg->message == WM_KEYDOWN) ||
1498 (msg->message == WM_CHAR))
1500 dlgCode = SendMessage16( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg16);
1502 ret = DIALOG_IsDialogMessage( WIN_Handle32(msg->hwnd), WIN_Handle32(hwndDlg),
1503 msg->message, msg->wParam, msg->lParam,
1504 &translate, &dispatch, dlgCode );
1505 if (translate) TranslateMessage16( msg );
1506 if (dispatch) DispatchMessage16( msg );
1507 return ret;
1511 /***********************************************************************
1512 * IsDialogMessage (USER32.@)
1513 * IsDialogMessageA (USER32.@)
1515 BOOL WINAPI IsDialogMessageA( HWND hwndDlg, LPMSG msg )
1517 BOOL ret, translate, dispatch;
1518 INT dlgCode = 0;
1520 hwndDlg = WIN_GetFullHandle( hwndDlg );
1521 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
1522 return FALSE;
1524 if ((msg->message == WM_KEYDOWN) ||
1525 (msg->message == WM_CHAR))
1527 dlgCode = SendMessageA( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1529 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1530 msg->wParam, msg->lParam,
1531 &translate, &dispatch, dlgCode );
1532 if (translate) TranslateMessage( msg );
1533 if (dispatch) DispatchMessageA( msg );
1534 return ret;
1538 /***********************************************************************
1539 * IsDialogMessageW (USER32.@)
1541 BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
1543 BOOL ret, translate, dispatch;
1544 INT dlgCode = 0;
1546 hwndDlg = WIN_GetFullHandle( hwndDlg );
1547 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd ))
1548 return FALSE;
1550 if ((msg->message == WM_KEYDOWN) ||
1551 (msg->message == WM_CHAR))
1553 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, 0, (LPARAM)msg);
1555 ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
1556 msg->wParam, msg->lParam,
1557 &translate, &dispatch, dlgCode );
1558 if (translate) TranslateMessage( msg );
1559 if (dispatch) DispatchMessageW( msg );
1560 return ret;
1564 /***********************************************************************
1565 * GetDlgCtrlID (USER32.@)
1567 INT WINAPI GetDlgCtrlID( HWND hwnd )
1569 return GetWindowLongW( hwnd, GWL_ID );
1573 /***********************************************************************
1574 * GetDlgItem (USER32.@)
1576 HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
1578 int i;
1579 HWND *list = WIN_ListChildren( hwndDlg );
1580 HWND ret = 0;
1582 if (!list) return 0;
1584 for (i = 0; list[i]; i++) if (GetWindowLongW( list[i], GWL_ID ) == id) break;
1585 ret = list[i];
1586 HeapFree( GetProcessHeap(), 0, list );
1587 return ret;
1591 /*******************************************************************
1592 * SendDlgItemMessageA (USER32.@)
1594 LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg,
1595 WPARAM wParam, LPARAM lParam )
1597 HWND hwndCtrl = GetDlgItem( hwnd, id );
1598 if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam );
1599 else return 0;
1603 /*******************************************************************
1604 * SendDlgItemMessageW (USER32.@)
1606 LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg,
1607 WPARAM wParam, LPARAM lParam )
1609 HWND hwndCtrl = GetDlgItem( hwnd, id );
1610 if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam );
1611 else return 0;
1615 /*******************************************************************
1616 * SetDlgItemTextA (USER32.@)
1618 BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString )
1620 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1624 /*******************************************************************
1625 * SetDlgItemTextW (USER32.@)
1627 BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString )
1629 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1633 /***********************************************************************
1634 * GetDlgItemTextA (USER32.@)
1636 INT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, UINT len )
1638 return (INT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT,
1639 len, (LPARAM)str );
1643 /***********************************************************************
1644 * GetDlgItemTextW (USER32.@)
1646 INT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, UINT len )
1648 return (INT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT,
1649 len, (LPARAM)str );
1653 /*******************************************************************
1654 * SetDlgItemInt (USER32.@)
1656 BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value,
1657 BOOL fSigned )
1659 char str[20];
1661 if (fSigned) sprintf( str, "%d", (INT)value );
1662 else sprintf( str, "%u", value );
1663 SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
1664 return TRUE;
1668 /***********************************************************************
1669 * GetDlgItemInt (USER32.@)
1671 UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated,
1672 BOOL fSigned )
1674 char str[30];
1675 char * endptr;
1676 long result = 0;
1678 if (translated) *translated = FALSE;
1679 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
1680 return 0;
1681 if (fSigned)
1683 result = strtol( str, &endptr, 10 );
1684 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1685 return 0;
1686 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1687 return 0;
1689 else
1691 result = strtoul( str, &endptr, 10 );
1692 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1693 return 0;
1694 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1696 if (translated) *translated = TRUE;
1697 return (UINT)result;
1701 /***********************************************************************
1702 * CheckDlgButton (USER32.@)
1704 BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check )
1706 SendDlgItemMessageA( hwnd, id, BM_SETCHECK, check, 0 );
1707 return TRUE;
1711 /***********************************************************************
1712 * IsDlgButtonChecked (USER32.@)
1714 UINT WINAPI IsDlgButtonChecked( HWND hwnd, UINT id )
1716 return (UINT)SendDlgItemMessageA( hwnd, id, BM_GETCHECK, 0, 0 );
1720 /***********************************************************************
1721 * CheckRB
1723 * Callback function used to check/uncheck radio buttons that fall
1724 * within a specific range of IDs.
1726 static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam)
1728 LONG lChildID = GetWindowLongA(hwndChild, GWL_ID);
1729 RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam;
1731 if ((lChildID >= lpRadioGroup->firstID) &&
1732 (lChildID <= lpRadioGroup->lastID))
1734 if (lChildID == lpRadioGroup->checkID)
1736 SendMessageA(hwndChild, BM_SETCHECK, BST_CHECKED, 0);
1738 else
1740 SendMessageA(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0);
1744 return TRUE;
1748 /***********************************************************************
1749 * CheckRadioButton (USER32.@)
1751 BOOL WINAPI CheckRadioButton( HWND hwndDlg, UINT firstID,
1752 UINT lastID, UINT checkID )
1754 RADIOGROUP radioGroup;
1756 /* perform bounds checking for a radio button group */
1757 radioGroup.firstID = min(min(firstID, lastID), checkID);
1758 radioGroup.lastID = max(max(firstID, lastID), checkID);
1759 radioGroup.checkID = checkID;
1761 return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB,
1762 (LPARAM)&radioGroup);
1766 /***********************************************************************
1767 * GetDialogBaseUnits (USER.243)
1768 * GetDialogBaseUnits (USER32.@)
1770 DWORD WINAPI GetDialogBaseUnits(void)
1772 return MAKELONG( xBaseUnit, yBaseUnit );
1776 /***********************************************************************
1777 * MapDialogRect (USER32.@)
1779 BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
1781 DIALOGINFO * dlgInfo;
1782 if (!(dlgInfo = DIALOG_get_info( hwnd ))) return FALSE;
1783 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1784 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1785 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1786 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
1787 return TRUE;
1791 /***********************************************************************
1792 * GetNextDlgGroupItem (USER32.@)
1794 HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1796 HWND hwnd, retvalue;
1798 hwndDlg = WIN_GetFullHandle( hwndDlg );
1799 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1801 if(hwndCtrl)
1803 /* if the hwndCtrl is the child of the control in the hwndDlg,
1804 * then the hwndDlg has to be the parent of the hwndCtrl */
1805 if(GetParent(hwndCtrl) != hwndDlg && GetParent(GetParent(hwndCtrl)) == hwndDlg)
1806 hwndDlg = GetParent(hwndCtrl);
1809 if (hwndCtrl)
1811 /* Make sure hwndCtrl is a top-level child */
1812 HWND parent = GetParent( hwndCtrl );
1813 while (parent && parent != hwndDlg) parent = GetParent(parent);
1814 if (parent != hwndDlg) return 0;
1816 else
1818 /* No ctrl specified -> start from the beginning */
1819 if (!(hwndCtrl = GetWindow( hwndDlg, GW_CHILD ))) return 0;
1820 if (fPrevious) hwndCtrl = GetWindow( hwndCtrl, GW_HWNDLAST );
1823 retvalue = hwndCtrl;
1824 hwnd = GetWindow( hwndCtrl, GW_HWNDNEXT );
1825 while (1)
1827 if (!hwnd || (GetWindowLongW( hwnd, GWL_STYLE ) & WS_GROUP))
1829 /* Wrap-around to the beginning of the group */
1830 HWND tmp;
1832 hwnd = GetWindow( hwndDlg, GW_CHILD );
1833 for (tmp = hwnd; tmp; tmp = GetWindow( tmp, GW_HWNDNEXT ) )
1835 if (GetWindowLongW( tmp, GWL_STYLE ) & WS_GROUP) hwnd = tmp;
1836 if (tmp == hwndCtrl) break;
1839 if (hwnd == hwndCtrl) break;
1840 if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE)
1842 retvalue = hwnd;
1843 if (!fPrevious) break;
1845 hwnd = GetWindow( hwnd, GW_HWNDNEXT );
1847 return retvalue;
1851 /***********************************************************************
1852 * DIALOG_GetNextTabItem
1854 * Helper for GetNextDlgTabItem
1856 static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1858 LONG dsStyle;
1859 LONG exStyle;
1860 UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
1861 HWND retWnd = 0;
1862 HWND hChildFirst = 0;
1864 if(!hwndCtrl)
1866 hChildFirst = GetWindow(hwndDlg,GW_CHILD);
1867 if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
1869 else if (IsChild( hwndMain, hwndCtrl ))
1871 hChildFirst = GetWindow(hwndCtrl,wndSearch);
1872 if(!hChildFirst)
1874 if(GetParent(hwndCtrl) != hwndMain)
1875 hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
1876 else
1878 if(fPrevious)
1879 hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST);
1880 else
1881 hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST);
1886 while(hChildFirst)
1888 BOOL bCtrl = FALSE;
1889 while(hChildFirst)
1891 dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
1892 exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
1893 if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1895 bCtrl=TRUE;
1896 break;
1898 else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1899 break;
1900 hChildFirst = GetWindow(hChildFirst,wndSearch);
1902 if(hChildFirst)
1904 if(bCtrl)
1905 retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,(HWND)NULL,fPrevious );
1906 else
1907 retWnd = hChildFirst;
1909 if(retWnd) break;
1910 hChildFirst = GetWindow(hChildFirst,wndSearch);
1912 if(!retWnd && hwndCtrl)
1914 HWND hParent = GetParent(hwndCtrl);
1915 while(hParent)
1917 if(hParent == hwndMain) break;
1918 retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
1919 if(retWnd) break;
1920 hParent = GetParent(hParent);
1922 if(!retWnd)
1923 retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,(HWND)NULL,fPrevious );
1925 return retWnd;
1928 /***********************************************************************
1929 * GetNextDlgTabItem (USER32.@)
1931 HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
1932 BOOL fPrevious )
1934 hwndDlg = WIN_GetFullHandle( hwndDlg );
1935 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1936 return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious);
1939 /**********************************************************************
1940 * DIALOG_DlgDirSelect
1942 * Helper function for DlgDirSelect*
1944 static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPSTR str, INT len,
1945 INT id, BOOL unicode, BOOL combo )
1947 char *buffer, *ptr;
1948 INT item, size;
1949 BOOL ret;
1950 HWND listbox = GetDlgItem( hwnd, id );
1952 TRACE("%04x '%s' %d\n", hwnd, str, id );
1953 if (!listbox) return FALSE;
1955 item = SendMessageA(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 );
1956 if (item == LB_ERR) return FALSE;
1957 size = SendMessageA(listbox, combo ? CB_GETLBTEXTLEN : LB_GETTEXTLEN, 0, 0 );
1958 if (size == LB_ERR) return FALSE;
1960 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size+1 ))) return FALSE;
1962 SendMessageA( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, item, (LPARAM)buffer );
1964 if ((ret = (buffer[0] == '['))) /* drive or directory */
1966 if (buffer[1] == '-') /* drive */
1968 buffer[3] = ':';
1969 buffer[4] = 0;
1970 ptr = buffer + 2;
1972 else
1974 buffer[strlen(buffer)-1] = '\\';
1975 ptr = buffer + 1;
1978 else ptr = buffer;
1980 if (unicode)
1982 if (len > 0 && !MultiByteToWideChar( CP_ACP, 0, ptr, -1, (LPWSTR)str, len ))
1983 ((LPWSTR)str)[len-1] = 0;
1985 else lstrcpynA( str, ptr, len );
1986 HeapFree( GetProcessHeap(), 0, buffer );
1987 TRACE("Returning %d '%s'\n", ret, str );
1988 return ret;
1992 /**********************************************************************
1993 * DIALOG_DlgDirList
1995 * Helper function for DlgDirList*
1997 static INT DIALOG_DlgDirList( HWND hDlg, LPSTR spec, INT idLBox,
1998 INT idStatic, UINT attrib, BOOL combo )
2000 HWND hwnd;
2001 LPSTR orig_spec = spec;
2003 #define SENDMSG(msg,wparam,lparam) \
2004 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
2005 : SendMessageA( hwnd, msg, wparam, lparam ))
2007 TRACE("%04x '%s' %d %d %04x\n",
2008 hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
2010 /* If the path exists and is a directory, chdir to it */
2011 if (!spec || !spec[0] || SetCurrentDirectoryA( spec )) spec = "*.*";
2012 else
2014 char *p, *p2;
2015 p = spec;
2016 if ((p2 = strrchr( p, '\\' ))) p = p2;
2017 if ((p2 = strrchr( p, '/' ))) p = p2;
2018 if (p != spec)
2020 char sep = *p;
2021 *p = 0;
2022 if (!SetCurrentDirectoryA( spec ))
2024 *p = sep; /* Restore the original spec */
2025 return FALSE;
2027 spec = p + 1;
2031 TRACE( "mask=%s\n", spec );
2033 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
2035 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
2036 if (attrib & DDL_DIRECTORY)
2038 if (!(attrib & DDL_EXCLUSIVE))
2040 if (SENDMSG( combo ? CB_DIR : LB_DIR,
2041 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
2042 (LPARAM)spec ) == LB_ERR)
2043 return FALSE;
2045 if (SENDMSG( combo ? CB_DIR : LB_DIR,
2046 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
2047 (LPARAM)"*.*" ) == LB_ERR)
2048 return FALSE;
2050 else
2052 if (SENDMSG( combo ? CB_DIR : LB_DIR, attrib,
2053 (LPARAM)spec ) == LB_ERR)
2054 return FALSE;
2058 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
2060 char temp[MAX_PATH];
2061 GetCurrentDirectoryA( sizeof(temp), temp );
2062 CharLowerA( temp );
2063 /* Can't use PostMessage() here, because the string is on the stack */
2064 SetDlgItemTextA( hDlg, idStatic, temp );
2067 if (orig_spec && (spec != orig_spec))
2069 /* Update the original file spec */
2070 char *p = spec;
2071 while ((*orig_spec++ = *p++));
2074 return TRUE;
2075 #undef SENDMSG
2079 /**********************************************************************
2080 * DIALOG_DlgDirListW
2082 * Helper function for DlgDirList*W
2084 static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2085 INT idStatic, UINT attrib, BOOL combo )
2087 if (spec)
2089 LPSTR specA = HEAP_strdupWtoA( GetProcessHeap(), 0, spec );
2090 INT ret = DIALOG_DlgDirList( hDlg, specA, idLBox, idStatic,
2091 attrib, combo );
2092 MultiByteToWideChar( CP_ACP, 0, specA, -1, spec, 0x7fffffff );
2093 HeapFree( GetProcessHeap(), 0, specA );
2094 return ret;
2096 return DIALOG_DlgDirList( hDlg, NULL, idLBox, idStatic, attrib, combo );
2100 /**********************************************************************
2101 * DlgDirSelectExA (USER32.@)
2103 BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id )
2105 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, FALSE );
2109 /**********************************************************************
2110 * DlgDirSelectExW (USER32.@)
2112 BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id )
2114 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, FALSE );
2118 /**********************************************************************
2119 * DlgDirSelectComboBoxExA (USER32.@)
2121 BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len,
2122 INT id )
2124 return DIALOG_DlgDirSelect( hwnd, str, len, id, FALSE, TRUE );
2128 /**********************************************************************
2129 * DlgDirSelectComboBoxExW (USER32.@)
2131 BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len,
2132 INT id)
2134 return DIALOG_DlgDirSelect( hwnd, (LPSTR)str, len, id, TRUE, TRUE );
2138 /**********************************************************************
2139 * DlgDirListA (USER32.@)
2141 INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
2142 INT idStatic, UINT attrib )
2144 return DIALOG_DlgDirList( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2148 /**********************************************************************
2149 * DlgDirListW (USER32.@)
2151 INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
2152 INT idStatic, UINT attrib )
2154 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
2158 /**********************************************************************
2159 * DlgDirListComboBoxA (USER32.@)
2161 INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox,
2162 INT idStatic, UINT attrib )
2164 return DIALOG_DlgDirList( hDlg, spec, idCBox, idStatic, attrib, TRUE );
2168 /**********************************************************************
2169 * DlgDirListComboBoxW (USER32.@)
2171 INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox,
2172 INT idStatic, UINT attrib )
2174 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );