1 /*
2 * Dialog functions
3 *
4 * Copyright 1993, 1994, 1996 Alexandre Julliard
5 *
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.
10 *
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.
15 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <ctype.h>
25 #include <errno.h>
26 #include <limits.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string.h>
31
32 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winuser.h"
36 #include "winnls.h"
37 #include "wine/winuser16.h"
38 #include "wine/unicode.h"
39 #include "controls.h"
40 #include "win.h"
41 #include "user_private.h"
42 #include "wine/debug.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(dialog);
45
46
47 /* Dialog control information */
48 typedef struct
49 {
50 DWORD style;
51 DWORD exStyle;
52 DWORD helpId;
53 INT16 x;
54 INT16 y;
55 INT16 cx;
56 INT16 cy;
57 UINT_PTR id;
58 LPCWSTR className;
59 LPCWSTR windowName;
60 LPCVOID data;
61 } DLG_CONTROL_INFO;
62
63 /* Dialog template */
64 typedef struct
65 {
66 DWORD style;
67 DWORD exStyle;
68 DWORD helpId;
69 UINT16 nbItems;
70 INT16 x;
71 INT16 y;
72 INT16 cx;
73 INT16 cy;
74 LPCWSTR menuName;
75 LPCWSTR className;
76 LPCWSTR caption;
77 INT16 pointSize;
78 WORD weight;
79 BOOL italic;
80 LPCWSTR faceName;
81 BOOL dialogEx;
82 } DLG_TEMPLATE;
83
84 /* Radio button group */
85 typedef struct
86 {
87 UINT firstID;
88 UINT lastID;
89 UINT checkID;
90 } RADIOGROUP;
91
92
93 /*********************************************************************
94 * dialog class descriptor
95 */
96 const struct builtin_class_descr DIALOG_builtin_class =
97 {
98 (LPCWSTR)DIALOG_CLASS_ATOM, /* name */
99 CS_SAVEBITS | CS_DBLCLKS, /* style */
100 DefDlgProcA, /* procA */
101 DefDlgProcW, /* procW */
102 DLGWINDOWEXTRA, /* extra */
103 IDC_ARROW, /* cursor */
104 0 /* brush */
105 };
106
107
108 /***********************************************************************
109 * DIALOG_EnableOwner
110 *
111 * Helper function for modal dialogs to enable again the
112 * owner of the dialog box.
113 */
114 void DIALOG_EnableOwner( HWND hOwner )
115 {
116 /* Owner must be a top-level window */
117 if (hOwner)
118 hOwner = GetAncestor( hOwner, GA_ROOT );
119 if (!hOwner) return;
120 EnableWindow( hOwner, TRUE );
121 }
122
123
124 /***********************************************************************
125 * DIALOG_DisableOwner
126 *
127 * Helper function for modal dialogs to disable the
128 * owner of the dialog box. Returns TRUE if owner was enabled.
129 */
130 BOOL DIALOG_DisableOwner( HWND hOwner )
131 {
132 /* Owner must be a top-level window */
133 if (hOwner)
134 hOwner = GetAncestor( hOwner, GA_ROOT );
135 if (!hOwner) return FALSE;
136 if (IsWindowEnabled( hOwner ))
137 {
138 EnableWindow( hOwner, FALSE );
139 return TRUE;
140 }
141 else
142 return FALSE;
143 }
144
145 /***********************************************************************
146 * DIALOG_GetControl32
147 *
148 * Return the class and text of the control pointed to by ptr,
149 * fill the header structure and return a pointer to the next control.
150 */
151 static const WORD *DIALOG_GetControl32( const WORD *p, DLG_CONTROL_INFO *info,
152 BOOL dialogEx )
153 {
154 if (dialogEx)
155 {
156 info->helpId = GET_DWORD(p); p += 2;
157 info->exStyle = GET_DWORD(p); p += 2;
158 info->style = GET_DWORD(p); p += 2;
159 }
160 else
161 {
162 info->helpId = 0;
163 info->style = GET_DWORD(p); p += 2;
164 info->exStyle = GET_DWORD(p); p += 2;
165 }
166 info->x = GET_WORD(p); p++;
167 info->y = GET_WORD(p); p++;
168 info->cx = GET_WORD(p); p++;
169 info->cy = GET_WORD(p); p++;
170
171 if (dialogEx)
172 {
173 /* id is a DWORD for DIALOGEX */
174 info->id = GET_DWORD(p);
175 p += 2;
176 }
177 else
178 {
179 info->id = GET_WORD(p);
180 p++;
181 }
182
183 if (GET_WORD(p) == 0xffff)
184 {
185 static const WCHAR class_names[6][10] =
186 {
187 { 'B','u','t','t','o','n', }, /* 0x80 */
188 { 'E','d','i','t', }, /* 0x81 */
189 { 'S','t','a','t','i','c', }, /* 0x82 */
190 { 'L','i','s','t','B','o','x', }, /* 0x83 */
191 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
192 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
193 };
194 WORD id = GET_WORD(p+1);
195 /* Windows treats dialog control class ids 0-5 same way as 0x80-0x85 */
196 if ((id >= 0x80) && (id <= 0x85)) id -= 0x80;
197 if (id <= 5)
198 info->className = class_names[id];
199 else
200 {
201 info->className = NULL;
202 ERR("Unknown built-in class id %04x\n", id );
203 }
204 p += 2;
205 }
206 else
207 {
208 info->className = p;
209 p += strlenW( info->className ) + 1;
210 }
211
212 if (GET_WORD(p) == 0xffff) /* Is it an integer id? */
213 {
214 info->windowName = MAKEINTRESOURCEW(GET_WORD(p + 1));
215 p += 2;
216 }
217 else
218 {
219 info->windowName = p;
220 p += strlenW( info->windowName ) + 1;
221 }
222
223 TRACE(" %s %s %ld, %d, %d, %d, %d, %08x, %08x, %08x\n",
224 debugstr_w( info->className ), debugstr_w( info->windowName ),
225 info->id, info->x, info->y, info->cx, info->cy,
226 info->style, info->exStyle, info->helpId );
227
228 if (GET_WORD(p))
229 {
230 if (TRACE_ON(dialog))
231 {
232 WORD i, count = GET_WORD(p) / sizeof(WORD);
233 TRACE(" BEGIN\n");
234 TRACE(" ");
235 for (i = 0; i < count; i++) TRACE( "%04x,", GET_WORD(p+i+1) );
236 TRACE("\n");
237 TRACE(" END\n" );
238 }
239 info->data = p + 1;
240 p += GET_WORD(p) / sizeof(WORD);
241 }
242 else info->data = NULL;
243 p++;
244
245 /* Next control is on dword boundary */
246 return (const WORD *)(((UINT_PTR)p + 3) & ~3);
247 }
248
249
250 /***********************************************************************
251 * DIALOG_CreateControls32
252 *
253 * Create the control windows for a dialog.
254 */
255 static BOOL DIALOG_CreateControls32( HWND hwnd, LPCSTR template, const DLG_TEMPLATE *dlgTemplate,
256 HINSTANCE hInst, BOOL unicode )
257 {
258 DIALOGINFO *dlgInfo = DIALOG_get_info( hwnd, TRUE );
259 DLG_CONTROL_INFO info;
260 HWND hwndCtrl, hwndDefButton = 0;
261 INT items = dlgTemplate->nbItems;
262
263 TRACE(" BEGIN\n" );
264 while (items--)
265 {
266 template = (LPCSTR)DIALOG_GetControl32( (const WORD *)template, &info,
267 dlgTemplate->dialogEx );
268 /* Is this it? */
269 if (info.style & WS_BORDER)
270 {
271 info.style &= ~WS_BORDER;
272 info.exStyle |= WS_EX_CLIENTEDGE;
273 }
274 if (unicode)
275 {
276 hwndCtrl = CreateWindowExW( info.exStyle | WS_EX_NOPARENTNOTIFY,
277 info.className, info.windowName,
278 info.style | WS_CHILD,
279 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
280 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
281 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
282 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
283 hwnd, (HMENU)info.id,
284 hInst, (LPVOID)info.data );
285 }
286 else
287 {
288 LPCSTR class = (LPCSTR)info.className;
289 LPCSTR caption = (LPCSTR)info.windowName;
290 LPSTR class_tmp = NULL;
291 LPSTR caption_tmp = NULL;
292
293 if (HIWORD(class))
294 {
295 DWORD len = WideCharToMultiByte( CP_ACP, 0, info.className, -1, NULL, 0, NULL, NULL );
296 class_tmp = HeapAlloc( GetProcessHeap(), 0, len );
297 WideCharToMultiByte( CP_ACP, 0, info.className, -1, class_tmp, len, NULL, NULL );
298 class = class_tmp;
299 }
300 if (HIWORD(caption))
301 {
302 DWORD len = WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, NULL, 0, NULL, NULL );
303 caption_tmp = HeapAlloc( GetProcessHeap(), 0, len );
304 WideCharToMultiByte( CP_ACP, 0, info.windowName, -1, caption_tmp, len, NULL, NULL );
305 caption = caption_tmp;
306 }
307 hwndCtrl = CreateWindowExA( info.exStyle | WS_EX_NOPARENTNOTIFY,
308 class, caption, info.style | WS_CHILD,
309 MulDiv(info.x, dlgInfo->xBaseUnit, 4),
310 MulDiv(info.y, dlgInfo->yBaseUnit, 8),
311 MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
312 MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
313 hwnd, (HMENU)info.id,
314 hInst, (LPVOID)info.data );
315 HeapFree( GetProcessHeap(), 0, class_tmp );
316 HeapFree( GetProcessHeap(), 0, caption_tmp );
317 }
318 if (!hwndCtrl)
319 {
320 if (dlgTemplate->style & DS_NOFAILCREATE) continue;
321 return FALSE;
322 }
323
324 /* Send initialisation messages to the control */
325 if (dlgInfo->hUserFont) SendMessageW( hwndCtrl, WM_SETFONT,
326 (WPARAM)dlgInfo->hUserFont, 0 );
327 if (SendMessageW(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
328 {
329 /* If there's already a default push-button, set it back */
330 /* to normal and use this one instead. */
331 if (hwndDefButton)
332 SendMessageW( hwndDefButton, BM_SETSTYLE, BS_PUSHBUTTON, FALSE );
333 hwndDefButton = hwndCtrl;
334 dlgInfo->idResult = GetWindowLongPtrA( hwndCtrl, GWLP_ID );
335 }
336 }
337 TRACE(" END\n" );
338 return TRUE;
339 }
340
341
342 /***********************************************************************
343 * DIALOG_ParseTemplate32
344 *
345 * Fill a DLG_TEMPLATE structure from the dialog template, and return
346 * a pointer to the first control.
347 */
348 static LPCSTR DIALOG_ParseTemplate32( LPCSTR template, DLG_TEMPLATE * result )
349 {
350 const WORD *p = (const WORD *)template;
351 WORD signature;
352 WORD dlgver;
353
354 signature = GET_WORD(p); p++;
355 dlgver = GET_WORD(p); p++;
356
357 if (signature == 1 && dlgver == 0xffff) /* DIALOGEX resource */
358 {
359 result->dialogEx = TRUE;
360 result->helpId = GET_DWORD(p); p += 2;
361 result->exStyle = GET_DWORD(p); p += 2;
362 result->style = GET_DWORD(p); p += 2;
363 }
364 else
365 {
366 result->style = GET_DWORD(p - 2);
367 result->dialogEx = FALSE;
368 result->helpId = 0;
369 result->exStyle = GET_DWORD(p); p += 2;
370 }
371 result->nbItems = GET_WORD(p); p++;
372 result->x = GET_WORD(p); p++;
373 result->y = GET_WORD(p); p++;
374 result->cx = GET_WORD(p); p++;
375 result->cy = GET_WORD(p); p++;
376 TRACE("DIALOG%s %d, %d, %d, %d, %d\n",
377 result->dialogEx ? "EX" : "", result->x, result->y,
378 result->cx, result->cy, result->helpId );
379 TRACE(" STYLE 0x%08x\n", result->style );
380 TRACE(" EXSTYLE 0x%08x\n", result->exStyle );
381
382 /* Get the menu name */
383
384 switch(GET_WORD(p))
385 {
386 case 0x0000:
387 result->menuName = NULL;
388 p++;
389 break;
390 case 0xffff:
391 result->menuName = MAKEINTRESOURCEW(GET_WORD( p + 1 ));
392 p += 2;
393 TRACE(" MENU %04x\n", LOWORD(result->menuName) );
394 break;
395 default:
396 result->menuName = p;
397 TRACE(" MENU %s\n", debugstr_w(result->menuName) );
398 p += strlenW( result->menuName ) + 1;
399 break;
400 }
401
402 /* Get the class name */
403
404 switch(GET_WORD(p))
405 {
406 case 0x0000:
407 result->className = (LPCWSTR)DIALOG_CLASS_ATOM;
408 p++;
409 break;
410 case 0xffff:
411 result->className = MAKEINTRESOURCEW(GET_WORD( p + 1 ));
412 p += 2;
413 TRACE(" CLASS %04x\n", LOWORD(result->className) );
414 break;
415 default:
416 result->className = p;
417 TRACE(" CLASS %s\n", debugstr_w( result->className ));
418 p += strlenW( result->className ) + 1;
419 break;
420 }
421
422 /* Get the window caption */
423
424 result->caption = p;
425 p += strlenW( result->caption ) + 1;
426 TRACE(" CAPTION %s\n", debugstr_w( result->caption ) );
427
428 /* Get the font name */
429
430 result->pointSize = 0;
431 result->faceName = NULL;
432 result->weight = FW_DONTCARE;
433 result->italic = FALSE;
434
435 if (result->style & DS_SETFONT)
436 {
437 result->pointSize = GET_WORD(p);
438 p++;
439
440 /* If pointSize is 0x7fff, it means that we need to use the font
441 * in NONCLIENTMETRICSW.lfMessageFont, and NOT read the weight,
442 * italic, and facename from the dialog template.
443 */
444 if (result->pointSize == 0x7fff)
445 {
446 /* We could call SystemParametersInfo here, but then we'd have
447 * to convert from pixel size to point size (which can be
448 * imprecise).
449 */
450 TRACE(" FONT: Using message box font\n");
451 }
452 else
453 {
454 if (result->dialogEx)
455 {
456 result->weight = GET_WORD(p); p++;
457 result->italic = LOBYTE(GET_WORD(p)); p++;
458 }
459 result->faceName = p;
460 p += strlenW( result->faceName ) + 1;
461
462 TRACE(" FONT %d, %s, %d, %s\n",
463 result->pointSize, debugstr_w( result->faceName ),
464 result->weight, result->italic ? "TRUE" : "FALSE" );
465 }
466 }
467
468 /* First control is on dword boundary */
469 return (LPCSTR)(((UINT_PTR)p + 3) & ~3);
470 }
471
472
473 /***********************************************************************
474 * DIALOG_CreateIndirect
475 * Creates a dialog box window
476 *
477 * modal = TRUE if we are called from a modal dialog box.
478 * (it's more compatible to do it here, as under Windows the owner
479 * is never disabled if the dialog fails because of an invalid template)
480 */
481 static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
482 HWND owner, DLGPROC dlgProc, LPARAM param,
483 BOOL unicode, BOOL modal )
484 {
485 HWND hwnd;
486 RECT rect;
487 POINT pos;
488 SIZE size;
489 DLG_TEMPLATE template;
490 DIALOGINFO * dlgInfo = NULL;
491 DWORD units = GetDialogBaseUnits();
492 BOOL ownerEnabled = TRUE;
493 HMENU hMenu = 0;
494 HFONT hUserFont = 0;
495 UINT flags = 0;
496 UINT xBaseUnit = LOWORD(units);
497 UINT yBaseUnit = HIWORD(units);
498
499 /* Parse dialog template */
500
501 if (!dlgTemplate) return 0;
502 dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
503
504 /* Load menu */
505
506 if (template.menuName) hMenu = LoadMenuW( hInst, template.menuName );
507
508 /* Create custom font if needed */
509
510 if (template.style & DS_SETFONT)
511 {
512 HDC dc = GetDC(0);
513
514 if (template.pointSize == 0x7fff)
515 {
516 /* We get the message font from the non-client metrics */
517 NONCLIENTMETRICSW ncMetrics;
518
519 ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
520 if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
521 sizeof(NONCLIENTMETRICSW), &ncMetrics, 0))
522 {
523 hUserFont = CreateFontIndirectW( &ncMetrics.lfMessageFont );
524 }
525 }
526 else
527 {
528 /* We convert the size to pixels and then make it -ve. This works
529 * for both +ve and -ve template.pointSize */
530 int pixels = MulDiv(template.pointSize, GetDeviceCaps(dc , LOGPIXELSY), 72);
531 hUserFont = CreateFontW( -pixels, 0, 0, 0, template.weight,
532 template.italic, FALSE, FALSE, DEFAULT_CHARSET, 0, 0,
533 PROOF_QUALITY, FF_DONTCARE,
534 template.faceName );
535 }
536
537 if (hUserFont)
538 {
539 SIZE charSize;
540 HFONT hOldFont = SelectObject( dc, hUserFont );
541 charSize.cx = GdiGetCharDimensions( dc, NULL, &charSize.cy );
542 if (charSize.cx)
543 {
544 xBaseUnit = charSize.cx;
545 yBaseUnit = charSize.cy;
546 }
547 SelectObject( dc, hOldFont );
548 }
549 ReleaseDC(0, dc);
550 TRACE("units = %d,%d\n", xBaseUnit, yBaseUnit );
551 }
552
553 /* Create dialog main window */
554
555 rect.left = rect.top = 0;
556 rect.right = MulDiv(template.cx, xBaseUnit, 4);
557 rect.bottom = MulDiv(template.cy, yBaseUnit, 8);
558 if (template.style & WS_CHILD)
559 template.style &= ~(WS_CAPTION|WS_SYSMENU);
560 if (template.style & DS_MODALFRAME)
561 template.exStyle |= WS_EX_DLGMODALFRAME;
562 if (template.style & DS_CONTROL)
563 template.exStyle |= WS_EX_CONTROLPARENT;
564 AdjustWindowRectEx( &rect, template.style, (hMenu != 0), template.exStyle );
565 pos.x = rect.left;
566 pos.y = rect.top;
567 size.cx = rect.right - rect.left;
568 size.cy = rect.bottom - rect.top;
569
570 if (template.x == CW_USEDEFAULT16)
571 {
572 pos.x = pos.y = CW_USEDEFAULT;
573 }
574 else
575 {
576 HMONITOR monitor = 0;
577 MONITORINFO mon_info;
578
579 mon_info.cbSize = sizeof(mon_info);
580 if (template.style & DS_CENTER)
581 {
582 monitor = MonitorFromWindow( owner ? owner : GetActiveWindow(), MONITOR_DEFAULTTOPRIMARY );
583 GetMonitorInfoW( monitor, &mon_info );
584 pos.x = (mon_info.rcWork.left + mon_info.rcWork.right - size.cx) / 2;
585 pos.y = (mon_info.rcWork.top + mon_info.rcWork.bottom - size.cy) / 2;
586 }
587 else if (template.style & DS_CENTERMOUSE)
588 {
589 GetCursorPos( &pos );
590 monitor = MonitorFromPoint( pos, MONITOR_DEFAULTTOPRIMARY );
591 GetMonitorInfoW( monitor, &mon_info );
592 }
593 else
594 {
595 pos.x += MulDiv(template.x, xBaseUnit, 4);
596 pos.y += MulDiv(template.y, yBaseUnit, 8);
597 if (!(template.style & (WS_CHILD|DS_ABSALIGN))) ClientToScreen( owner, &pos );
598 }
599 if ( !(template.style & WS_CHILD) )
600 {
601 INT dX, dY;
602
603 /* try to fit it into the desktop */
604
605 if (!monitor)
606 {
607 SetRect( &rect, pos.x, pos.y, pos.x + size.cx, pos.y + size.cy );
608 monitor = MonitorFromRect( &rect, MONITOR_DEFAULTTOPRIMARY );
609 GetMonitorInfoW( monitor, &mon_info );
610 }
611 if ((dX = pos.x + size.cx + GetSystemMetrics(SM_CXDLGFRAME) - mon_info.rcWork.right) > 0)
612 pos.x -= dX;
613 if ((dY = pos.y + size.cy + GetSystemMetrics(SM_CYDLGFRAME) - mon_info.rcWork.bottom) > 0)
614 pos.y -= dY;
615 if( pos.x < mon_info.rcWork.left ) pos.x = mon_info.rcWork.left;
616 if( pos.y < mon_info.rcWork.top ) pos.y = mon_info.rcWork.top;
617 }
618 }
619
620 if (modal)
621 {
622 ownerEnabled = DIALOG_DisableOwner( owner );
623 if (ownerEnabled) flags |= DF_OWNERENABLED;
624 }
625
626 if (unicode)
627 {
628 hwnd = CreateWindowExW(template.exStyle, template.className, template.caption,
629 template.style & ~WS_VISIBLE, pos.x, pos.y, size.cx, size.cy,
630 owner, hMenu, hInst, NULL );
631 }
632 else
633 {
634 LPCSTR class = (LPCSTR)template.className;
635 LPCSTR caption = (LPCSTR)template.caption;
636 LPSTR class_tmp = NULL;
637 LPSTR caption_tmp = NULL;
638
639 if (HIWORD(class))
640 {
641 DWORD len = WideCharToMultiByte( CP_ACP, 0, template.className, -1, NULL, 0, NULL, NULL );
642 class_tmp = HeapAlloc( GetProcessHeap(), 0, len );
643 WideCharToMultiByte( CP_ACP, 0, template.className, -1, class_tmp, len, NULL, NULL );
644 class = class_tmp;
645 }
646 if (HIWORD(caption))
647 {
648 DWORD len = WideCharToMultiByte( CP_ACP, 0, template.caption, -1, NULL, 0, NULL, NULL );
649 caption_tmp = HeapAlloc( GetProcessHeap(), 0, len );
650 WideCharToMultiByte( CP_ACP, 0, template.caption, -1, caption_tmp, len, NULL, NULL );
651 caption = caption_tmp;
652 }
653 hwnd = CreateWindowExA(template.exStyle, class, caption,
654 template.style & ~WS_VISIBLE, pos.x, pos.y, size.cx, size.cy,
655 owner, hMenu, hInst, NULL );
656 HeapFree( GetProcessHeap(), 0, class_tmp );
657 HeapFree( GetProcessHeap(), 0, caption_tmp );
658 }
659
660 if (!hwnd)
661 {
662 if (hUserFont) DeleteObject( hUserFont );
663 if (hMenu) DestroyMenu( hMenu );
664 if (modal && (flags & DF_OWNERENABLED)) DIALOG_EnableOwner(owner);
665 return 0;
666 }
667
668 /* moved this from the top of the method to here as DIALOGINFO structure
669 will be valid only after WM_CREATE message has been handled in DefDlgProc
670 All the members of the structure get filled here using temp variables */
671 dlgInfo = DIALOG_get_info( hwnd, TRUE );
672 dlgInfo->hwndFocus = 0;
673 dlgInfo->hUserFont = hUserFont;
674 dlgInfo->hMenu = hMenu;
675 dlgInfo->xBaseUnit = xBaseUnit;
676 dlgInfo->yBaseUnit = yBaseUnit;
677 dlgInfo->idResult = IDOK;
678 dlgInfo->flags = flags;
679 dlgInfo->hDialogHeap = 0;
680
681 if (template.helpId) SetWindowContextHelpId( hwnd, template.helpId );
682
683 if (unicode) SetWindowLongPtrW( hwnd, DWLP_DLGPROC, (ULONG_PTR)dlgProc );
684 else SetWindowLongPtrA( hwnd, DWLP_DLGPROC, (ULONG_PTR)dlgProc );
685
686 if (dlgProc && dlgInfo->hUserFont)
687 SendMessageW( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
688
689 /* Create controls */
690
691 if (DIALOG_CreateControls32( hwnd, dlgTemplate, &template, hInst, unicode ))
692 {
693 /* Send initialisation messages and set focus */
694
695 if (dlgProc)
696 {
697 if (SendMessageW( hwnd, WM_INITDIALOG, (WPARAM)dlgInfo->hwndFocus, param ) &&
698 ((~template.style & DS_CONTROL) || (template.style & WS_VISIBLE)))
699 {
700 /* By returning TRUE, app has requested a default focus assignment */
701 dlgInfo->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE);
702 if( dlgInfo->hwndFocus )
703 SetFocus( dlgInfo->hwndFocus );
704 }
705 }
706
707 if (template.style & WS_VISIBLE && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
708 {
709 ShowWindow( hwnd, SW_SHOWNORMAL ); /* SW_SHOW doesn't always work */
710 }
711 return hwnd;
712 }
713 if (modal && ownerEnabled) DIALOG_EnableOwner(owner);
714 if( IsWindow(hwnd) ) DestroyWindow( hwnd );
715 return 0;
716 }
717
718
719 /***********************************************************************
720 * CreateDialogParamA (USER32.@)
721 */
722 HWND WINAPI CreateDialogParamA( HINSTANCE hInst, LPCSTR name, HWND owner,
723 DLGPROC dlgProc, LPARAM param )
724 {
725 HRSRC hrsrc;
726 LPCDLGTEMPLATEA ptr;
727
728 if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return 0;
729 if (!(ptr = LoadResource(hInst, hrsrc))) return 0;
730 return CreateDialogIndirectParamA( hInst, ptr, owner, dlgProc, param );
731 }
732
733
734 /***********************************************************************
735 * CreateDialogParamW (USER32.@)
736 */
737 HWND WINAPI CreateDialogParamW( HINSTANCE hInst, LPCWSTR name, HWND owner,
738 DLGPROC dlgProc, LPARAM param )
739 {
740 HRSRC hrsrc;
741 LPCDLGTEMPLATEA ptr;
742
743 if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return 0;
744 if (!(ptr = LoadResource(hInst, hrsrc))) return 0;
745 return CreateDialogIndirectParamW( hInst, ptr, owner, dlgProc, param );
746 }
747
748
749 /***********************************************************************
750 * CreateDialogIndirectParamAorW (USER32.@)
751 */
752 HWND WINAPI CreateDialogIndirectParamAorW( HINSTANCE hInst, LPCVOID dlgTemplate,
753 HWND owner, DLGPROC dlgProc, LPARAM param,
754 DWORD flags )
755 {
756 return DIALOG_CreateIndirect( hInst, dlgTemplate, owner, dlgProc, param, !flags, FALSE );
757 }
758
759 /***********************************************************************
760 * CreateDialogIndirectParamA (USER32.@)
761 */
762 HWND WINAPI CreateDialogIndirectParamA( HINSTANCE hInst, LPCDLGTEMPLATEA dlgTemplate,
763 HWND owner, DLGPROC dlgProc, LPARAM param )
764 {
765 return CreateDialogIndirectParamAorW( hInst, dlgTemplate, owner, dlgProc, param, 2 );
766 }
767
768 /***********************************************************************
769 * CreateDialogIndirectParamW (USER32.@)
770 */
771 HWND WINAPI CreateDialogIndirectParamW( HINSTANCE hInst, LPCDLGTEMPLATEW dlgTemplate,
772 HWND owner, DLGPROC dlgProc, LPARAM param )
773 {
774 return CreateDialogIndirectParamAorW( hInst, dlgTemplate, owner, dlgProc, param, 0 );
775 }
776
777
778 /***********************************************************************
779 * DIALOG_DoDialogBox
780 */
781 INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
782 {
783 DIALOGINFO * dlgInfo;
784 MSG msg;
785 INT retval;
786 HWND ownerMsg = GetAncestor( owner, GA_ROOT );
787 BOOL bFirstEmpty;
788
789 if (!(dlgInfo = DIALOG_get_info( hwnd, FALSE ))) return -1;
790
791 bFirstEmpty = TRUE;
792 if (!(dlgInfo->flags & DF_END)) /* was EndDialog called in WM_INITDIALOG ? */
793 {
794 for (;;)
795 {
796 if (!PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
797 {
798 if (bFirstEmpty)
799 {
800 /* ShowWindow the first time the queue goes empty */
801 ShowWindow( hwnd, SW_SHOWNORMAL );
802 bFirstEmpty = FALSE;
803 }
804 if (!(GetWindowLongW( hwnd, GWL_STYLE ) & DS_NOIDLEMSG))
805 {
806 /* No message present -> send ENTERIDLE and wait */
807 SendMessageW( ownerMsg, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)hwnd );
808 }
809 if (!GetMessageW( &msg, 0, 0, 0 )) break;
810 }
811
812 if (!IsWindow( hwnd )) return 0;
813 if (!(dlgInfo->flags & DF_END) && !IsDialogMessageW( hwnd, &msg))
814 {
815 TranslateMessage( &msg );
816 DispatchMessageW( &msg );
817 }
818 if (dlgInfo->flags & DF_END) break;
819 }
820 }
821 if (dlgInfo->flags & DF_OWNERENABLED) DIALOG_EnableOwner( owner );
822 retval = dlgInfo->idResult;
823 DestroyWindow( hwnd );
824 return retval;
825 }
826
827
828 /***********************************************************************
829 * DialogBoxParamA (USER32.@)
830 */
831 INT_PTR WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name,
832 HWND owner, DLGPROC dlgProc, LPARAM param )
833 {
834 HWND hwnd;
835 HRSRC hrsrc;
836 LPCDLGTEMPLATEA ptr;
837
838 if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return -1;
839 if (!(ptr = LoadResource(hInst, hrsrc))) return -1;
840 hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, FALSE, TRUE );
841 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
842 return 0;
843 }
844
845
846 /***********************************************************************
847 * DialogBoxParamW (USER32.@)
848 */
849 INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name,
850 HWND owner, DLGPROC dlgProc, LPARAM param )
851 {
852 HWND hwnd;
853 HRSRC hrsrc;
854 LPCDLGTEMPLATEW ptr;
855
856 if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return -1;
857 if (!(ptr = LoadResource(hInst, hrsrc))) return -1;
858 hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, TRUE, TRUE );
859 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
860 return 0;
861 }
862
863
864 /***********************************************************************
865 * DialogBoxIndirectParamAorW (USER32.@)
866 */
867 INT_PTR WINAPI DialogBoxIndirectParamAorW( HINSTANCE hInstance, LPCVOID template,
868 HWND owner, DLGPROC dlgProc,
869 LPARAM param, DWORD flags )
870 {
871 HWND hwnd = DIALOG_CreateIndirect( hInstance, template, owner, dlgProc, param, !flags, TRUE );
872 if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
873 return -1;
874 }
875
876 /***********************************************************************
877 * DialogBoxIndirectParamA (USER32.@)
878 */
879 INT_PTR WINAPI DialogBoxIndirectParamA(HINSTANCE hInstance, LPCDLGTEMPLATEA template,
880 HWND owner, DLGPROC dlgProc, LPARAM param )
881 {
882 return DialogBoxIndirectParamAorW( hInstance, template, owner, dlgProc, param, 2 );
883 }
884
885
886 /***********************************************************************
887 * DialogBoxIndirectParamW (USER32.@)
888 */
889 INT_PTR WINAPI DialogBoxIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW template,
890 HWND owner, DLGPROC dlgProc, LPARAM param )
891 {
892 return DialogBoxIndirectParamAorW( hInstance, template, owner, dlgProc, param, 0 );
893 }
894
895 /***********************************************************************
896 * EndDialog (USER32.@)
897 */
898 BOOL WINAPI EndDialog( HWND hwnd, INT_PTR retval )
899 {
900 BOOL wasEnabled = TRUE;
901 DIALOGINFO * dlgInfo;
902 HWND owner;
903
904 TRACE("%p %ld\n", hwnd, retval );
905
906 if (!(dlgInfo = DIALOG_get_info( hwnd, FALSE )))
907 {
908 ERR("got invalid window handle (%p); buggy app !?\n", hwnd);
909 return FALSE;
910 }
911 dlgInfo->idResult = retval;
912 dlgInfo->flags |= DF_END;
913 wasEnabled = (dlgInfo->flags & DF_OWNERENABLED);
914
915 if (wasEnabled && (owner = GetWindow( hwnd, GW_OWNER )))
916 DIALOG_EnableOwner( owner );
917
918 /* Windows sets the focus to the dialog itself in EndDialog */
919
920 if (IsChild(hwnd, GetFocus()))
921 SetFocus( hwnd );
922
923 /* Don't have to send a ShowWindow(SW_HIDE), just do
924 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
925
926 SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE
927 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_HIDEWINDOW);
928
929 if (hwnd == GetActiveWindow()) WINPOS_ActivateOtherWindow( hwnd );
930
931 /* unblock dialog loop */
932 PostMessageA(hwnd, WM_NULL, 0, 0);
933 return TRUE;
934 }
935
936
937 /***********************************************************************
938 * DIALOG_IsAccelerator
939 */
940 static BOOL DIALOG_IsAccelerator( HWND hwnd, HWND hwndDlg, WPARAM wParam )
941 {
942 HWND hwndControl = hwnd;
943 HWND hwndNext;
944 INT dlgCode;
945 WCHAR buffer[128];
946
947 do
948 {
949 DWORD style = GetWindowLongW( hwndControl, GWL_STYLE );
950 if ((style & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE)
951 {
952 dlgCode = SendMessageW( hwndControl, WM_GETDLGCODE, 0, 0 );
953 if ( (dlgCode & (DLGC_BUTTON | DLGC_STATIC)) &&
954 GetWindowTextW( hwndControl, buffer, sizeof(buffer)/sizeof(WCHAR) ))
955 {
956 /* find the accelerator key */
957 LPWSTR p = buffer - 2;
958
959 do
960 {
961 p = strchrW( p + 2, '&' );
962 }
963 while (p != NULL && p[1] == '&');
964
965 /* and check if it's the one we're looking for */
966 if (p != NULL && toupperW( p[1] ) == toupperW( wParam ) )
967 {
968 if ((dlgCode & DLGC_STATIC) || (style & 0x0f) == BS_GROUPBOX )
969 {
970 /* set focus to the control */
971 SendMessageW( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndControl, 1);
972 /* and bump it on to next */
973 SendMessageW( hwndDlg, WM_NEXTDLGCTL, 0, 0);
974 }
975 else if (dlgCode & DLGC_BUTTON)
976 {
977 /* send BM_CLICK message to the control */
978 SendMessageW( hwndControl, BM_CLICK, 0, 0 );
979 }
980 return TRUE;
981 }
982 }
983 hwndNext = GetWindow( hwndControl, GW_CHILD );
984 }
985 else hwndNext = 0;
986
987 if (!hwndNext) hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
988
989 while (!hwndNext && hwndControl)
990 {
991 hwndControl = GetParent( hwndControl );
992 if (hwndControl == hwndDlg)
993 {
994 if(hwnd==hwndDlg) /* prevent endless loop */
995 {
996 hwndNext=hwnd;
997 break;
998 }
999 hwndNext = GetWindow( hwndDlg, GW_CHILD );
1000 }
1001 else
1002 hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
1003 }
1004 hwndControl = hwndNext;
1005 }
1006 while (hwndControl && (hwndControl != hwnd));
1007
1008 return FALSE;
1009 }
1010
1011 /***********************************************************************
1012 * DIALOG_FindMsgDestination
1013 *
1014 * The messages that IsDialogMessage sends may not go to the dialog
1015 * calling IsDialogMessage if that dialog is a child, and it has the
1016 * DS_CONTROL style set.
1017 * We propagate up until we hit one that does not have DS_CONTROL, or
1018 * whose parent is not a dialog.
1019 *
1020 * This is undocumented behaviour.
1021 */
1022 static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
1023 {
1024 while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL)
1025 {
1026 WND *pParent;
1027 HWND hParent = GetParent(hwndDlg);
1028 if (!hParent) break;
1029
1030 pParent = WIN_GetPtr(hParent);
1031 if (!pParent || pParent == WND_OTHER_PROCESS || pParent == WND_DESKTOP) break;
1032
1033 if (!(pParent->flags & WIN_ISDIALOG))
1034 {
1035 WIN_ReleasePtr(pParent);
1036 break;
1037 }
1038 WIN_ReleasePtr(pParent);
1039
1040 hwndDlg = hParent;
1041 }
1042
1043 return hwndDlg;
1044 }
1045
1046 /***********************************************************************
1047 * DIALOG_FixOneChildOnChangeFocus
1048 *
1049 * Callback helper for DIALOG_FixChildrenOnChangeFocus
1050 */
1051
1052 static BOOL CALLBACK DIALOG_FixOneChildOnChangeFocus (HWND hwndChild,
1053 LPARAM lParam)
1054 {
1055 /* If a default pushbutton then no longer default */
1056 if (DLGC_DEFPUSHBUTTON & SendMessageW (hwndChild, WM_GETDLGCODE, 0, 0))
1057 SendMessageW (hwndChild, BM_SETSTYLE, BS_PUSHBUTTON, TRUE);
1058 return TRUE;
1059 }
1060
1061 /***********************************************************************
1062 * DIALOG_FixChildrenOnChangeFocus
1063 *
1064 * Following the change of focus that occurs for example after handling
1065 * a WM_KEYDOWN VK_TAB in IsDialogMessage, some tidying of the dialog's
1066 * children may be required.
1067 */
1068 static void DIALOG_FixChildrenOnChangeFocus (HWND hwndDlg, HWND hwndNext)
1069 {
1070 INT dlgcode_next = SendMessageW (hwndNext, WM_GETDLGCODE, 0, 0);
1071 /* INT dlgcode_dlg = SendMessageW (hwndDlg, WM_GETDLGCODE, 0, 0); */
1072 /* Windows does ask for this. I don't know why yet */
1073
1074 EnumChildWindows (hwndDlg, DIALOG_FixOneChildOnChangeFocus, 0);
1075
1076 /* If the button that is getting the focus WAS flagged as the default
1077 * pushbutton then ask the dialog what it thinks the default is and
1078 * set that in the default style.
1079 */
1080 if (dlgcode_next & DLGC_DEFPUSHBUTTON)
1081 {
1082 DWORD def_id = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0);
1083 if (HIWORD(def_id) == DC_HASDEFID)
1084 {
1085 HWND hwndDef;
1086 def_id = LOWORD(def_id);
1087 hwndDef = GetDlgItem (hwndDlg, def_id);
1088 if (hwndDef)
1089 {
1090 INT dlgcode_def = SendMessageW (hwndDef, WM_GETDLGCODE, 0, 0);
1091 /* I know that if it is a button then it should already be a
1092 * UNDEFPUSHBUTTON, since we have just told the buttons to
1093 * change style. But maybe they ignored our request
1094 */
1095 if ((dlgcode_def & DLGC_BUTTON) &&
1096 (dlgcode_def & DLGC_UNDEFPUSHBUTTON))
1097 {
1098 SendMessageW (hwndDef, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
1099 }
1100 }
1101 }
1102 }
1103 else if ((dlgcode_next & DLGC_BUTTON) && (dlgcode_next & DLGC_UNDEFPUSHBUTTON))
1104 {
1105 SendMessageW (hwndNext, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE);
1106 /* I wonder why it doesn't send a DM_SETDEFID */
1107 }
1108 }
1109
1110 /***********************************************************************
1111 * IsDialogMessageW (USER32.@)
1112 */
1113 BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
1114 {
1115 INT dlgCode = 0;
1116
1117 if (CallMsgFilterW( msg, MSGF_DIALOGBOX )) return TRUE;
1118
1119 hwndDlg = WIN_GetFullHandle( hwndDlg );
1120 if (is_desktop_window(hwndDlg)) return FALSE;
1121 if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) return FALSE;
1122
1123 hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
1124
1125 switch(msg->message)
1126 {
1127 case WM_KEYDOWN:
1128 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, msg->wParam, (LPARAM)msg );
1129 if (dlgCode & (DLGC_WANTMESSAGE)) break;
1130
1131 switch(msg->wParam)
1132 {
1133 case VK_TAB:
1134 if (!(dlgCode & DLGC_WANTTAB))
1135 {
1136 BOOL fIsDialog = TRUE;
1137 WND *pWnd = WIN_GetPtr( hwndDlg );
1138
1139 if (pWnd && pWnd != WND_OTHER_PROCESS)
1140 {
1141 fIsDialog = (pWnd->flags & WIN_ISDIALOG) != 0;
1142 WIN_ReleasePtr(pWnd);
1143 }
1144
1145 /* I am not sure under which circumstances the TAB is handled
1146 * each way. All I do know is that it does not always simply
1147 * send WM_NEXTDLGCTL. (Personally I have never yet seen it
1148 * do so but I presume someone has)
1149 */
1150 if (fIsDialog)
1151 SendMessageW( hwndDlg, WM_NEXTDLGCTL, (GetKeyState(VK_SHIFT) & 0x8000), 0 );
1152 else
1153 {
1154 /* It would appear that GetNextDlgTabItem can handle being
1155 * passed hwndDlg rather than NULL but that is undocumented
1156 * so let's do it properly
1157 */
1158 HWND hwndFocus = GetFocus();
1159 HWND hwndNext = GetNextDlgTabItem (hwndDlg,
1160 hwndFocus == hwndDlg ? NULL : hwndFocus,
1161 GetKeyState (VK_SHIFT) & 0x8000);
1162 if (hwndNext)
1163 {
1164 dlgCode = SendMessageW (hwndNext, WM_GETDLGCODE,
1165 msg->wParam, (LPARAM)msg);
1166 if (dlgCode & DLGC_HASSETSEL)
1167 {
1168 INT maxlen = 1 + SendMessageW (hwndNext, WM_GETTEXTLENGTH, 0, 0);
1169 WCHAR *buffer = HeapAlloc (GetProcessHeap(), 0, maxlen * sizeof(WCHAR));
1170 if (buffer)
1171 {
1172 INT length;
1173 SendMessageW (hwndNext, WM_GETTEXT, maxlen, (LPARAM) buffer);
1174 length = strlenW (buffer);
1175 HeapFree (GetProcessHeap(), 0, buffer);
1176 SendMessageW (hwndNext, EM_SETSEL, 0, length);
1177 }
1178 }
1179 SetFocus (hwndNext);
1180 DIALOG_FixChildrenOnChangeFocus (hwndDlg, hwndNext);
1181 }
1182 else
1183 return FALSE;
1184 }
1185 return TRUE;
1186 }
1187 break;
1188
1189 case VK_RIGHT:
1190 case VK_DOWN:
1191 case VK_LEFT:
1192 case VK_UP:
1193 if (!(dlgCode & DLGC_WANTARROWS))
1194 {
1195 BOOL fPrevious = (msg->wParam == VK_LEFT || msg->wParam == VK_UP);
1196 HWND hwndNext = GetNextDlgGroupItem (hwndDlg, GetFocus(), fPrevious );
1197 SendMessageW( hwndDlg, WM_NEXTDLGCTL, (WPARAM)hwndNext, 1 );
1198 return TRUE;
1199 }
1200 break;
1201
1202 case VK_CANCEL:
1203 case VK_ESCAPE:
1204 SendMessageW( hwndDlg, WM_COMMAND, IDCANCEL, (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
1205 return TRUE;
1206
1207 case VK_EXECUTE:
1208 case VK_RETURN:
1209 {
1210 DWORD dw;
1211 if ((GetFocus() == msg->hwnd) &&
1212 (SendMessageW (msg->hwnd, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
1213 {
1214 SendMessageW (hwndDlg, WM_COMMAND, MAKEWPARAM (GetDlgCtrlID(msg->hwnd),BN_CLICKED), (LPARAM)msg->hwnd);
1215 }
1216 else if (DC_HASDEFID == HIWORD(dw = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0)))
1217 {
1218 HWND hwndDef = GetDlgItem(hwndDlg, LOWORD(dw));
1219 if (!hwndDef || !IsWindowEnabled(hwndDef))
1220 return TRUE;
1221 SendMessageW( hwndDlg, WM_COMMAND, MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
1222 (LPARAM)GetDlgItem(hwndDlg, LOWORD(dw)));
1223 }
1224 else
1225 {
1226 SendMessageW( hwndDlg, WM_COMMAND, IDOK, (LPARAM)GetDlgItem( hwndDlg, IDOK ) );
1227
1228 }
1229 }
1230 return TRUE;
1231 }
1232 break;
1233
1234 case WM_CHAR:
1235 /* FIXME Under what circumstances does WM_GETDLGCODE get sent?
1236 * It does NOT get sent in the test program I have
1237 */
1238 dlgCode = SendMessageW( msg->hwnd, WM_GETDLGCODE, msg->wParam, (LPARAM)msg );
1239 if (dlgCode & (DLGC_WANTCHARS|DLGC_WANTMESSAGE)) break;
1240 if (msg->wParam == '\t' && (dlgCode & DLGC_WANTTAB)) break;
1241 /* drop through */
1242
1243 case WM_SYSCHAR:
1244 if (DIALOG_IsAccelerator( WIN_GetFullHandle(msg->hwnd), hwndDlg, msg->wParam ))
1245 {
1246 /* don't translate or dispatch */
1247 return TRUE;
1248 }
1249 break;
1250 }
1251
1252 TranslateMessage( msg );
1253 DispatchMessageW( msg );
1254 return TRUE;
1255 }
1256
1257
1258 /***********************************************************************
1259 * GetDlgCtrlID (USER32.@)
1260 */
1261 INT WINAPI GetDlgCtrlID( HWND hwnd )
1262 {
1263 return GetWindowLongPtrW( hwnd, GWLP_ID );
1264 }
1265
1266
1267 /***********************************************************************
1268 * GetDlgItem (USER32.@)
1269 */
1270 HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
1271 {
1272 int i;
1273 HWND *list = WIN_ListChildren( hwndDlg );
1274 HWND ret = 0;
1275
1276 if (!list) return 0;
1277
1278 for (i = 0; list[i]; i++) if (GetWindowLongPtrW( list[i], GWLP_ID ) == id) break;
1279 ret = list[i];
1280 HeapFree( GetProcessHeap(), 0, list );
1281 return ret;
1282 }
1283
1284
1285 /*******************************************************************
1286 * SendDlgItemMessageA (USER32.@)
1287 */
1288 LRESULT WINAPI SendDlgItemMessageA( HWND hwnd, INT id, UINT msg,
1289 WPARAM wParam, LPARAM lParam )
1290 {
1291 HWND hwndCtrl = GetDlgItem( hwnd, id );
1292 if (hwndCtrl) return SendMessageA( hwndCtrl, msg, wParam, lParam );
1293 else return 0;
1294 }
1295
1296
1297 /*******************************************************************
1298 * SendDlgItemMessageW (USER32.@)
1299 */
1300 LRESULT WINAPI SendDlgItemMessageW( HWND hwnd, INT id, UINT msg,
1301 WPARAM wParam, LPARAM lParam )
1302 {
1303 HWND hwndCtrl = GetDlgItem( hwnd, id );
1304 if (hwndCtrl) return SendMessageW( hwndCtrl, msg, wParam, lParam );
1305 else return 0;
1306 }
1307
1308
1309 /*******************************************************************
1310 * SetDlgItemTextA (USER32.@)
1311 */
1312 BOOL WINAPI SetDlgItemTextA( HWND hwnd, INT id, LPCSTR lpString )
1313 {
1314 return SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1315 }
1316
1317
1318 /*******************************************************************
1319 * SetDlgItemTextW (USER32.@)
1320 */
1321 BOOL WINAPI SetDlgItemTextW( HWND hwnd, INT id, LPCWSTR lpString )
1322 {
1323 return SendDlgItemMessageW( hwnd, id, WM_SETTEXT, 0, (LPARAM)lpString );
1324 }
1325
1326
1327 /***********************************************************************
1328 * GetDlgItemTextA (USER32.@)
1329 */
1330 UINT WINAPI GetDlgItemTextA( HWND hwnd, INT id, LPSTR str, INT len )
1331 {
1332 if (str && (len > 0)) str[0] = '\0';
1333 return (UINT)SendDlgItemMessageA( hwnd, id, WM_GETTEXT,
1334 len, (LPARAM)str );
1335 }
1336
1337
1338 /***********************************************************************
1339 * GetDlgItemTextW (USER32.@)
1340 */
1341 UINT WINAPI GetDlgItemTextW( HWND hwnd, INT id, LPWSTR str, INT len )
1342 {
1343 if (str && (len > 0)) str[0] = '\0';
1344 return (UINT)SendDlgItemMessageW( hwnd, id, WM_GETTEXT,
1345 len, (LPARAM)str );
1346 }
1347
1348
1349 /*******************************************************************
1350 * SetDlgItemInt (USER32.@)
1351 */
1352 BOOL WINAPI SetDlgItemInt( HWND hwnd, INT id, UINT value,
1353 BOOL fSigned )
1354 {
1355 char str[20];
1356
1357 if (fSigned) sprintf( str, "%d", (INT)value );
1358 else sprintf( str, "%u", value );
1359 SendDlgItemMessageA( hwnd, id, WM_SETTEXT, 0, (LPARAM)str );
1360 return TRUE;
1361 }
1362
1363
1364 /***********************************************************************
1365 * GetDlgItemInt (USER32.@)
1366 */
1367 UINT WINAPI GetDlgItemInt( HWND hwnd, INT id, BOOL *translated,
1368 BOOL fSigned )
1369 {
1370 char str[30];
1371 char * endptr;
1372 long result = 0;
1373
1374 if (translated) *translated = FALSE;
1375 if (!SendDlgItemMessageA(hwnd, id, WM_GETTEXT, sizeof(str), (LPARAM)str))
1376 return 0;
1377 if (fSigned)
1378 {
1379 result = strtol( str, &endptr, 10 );
1380 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1381 return 0;
1382 if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno==ERANGE))
1383 return 0;
1384 }
1385 else
1386 {
1387 result = strtoul( str, &endptr, 10 );
1388 if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
1389 return 0;
1390 if ((result == ULONG_MAX) && (errno == ERANGE)) return 0;
1391 }
1392 if (translated) *translated = TRUE;
1393 return (UINT)result;
1394 }
1395
1396
1397 /***********************************************************************
1398 * CheckDlgButton (USER32.@)
1399 */
1400 BOOL WINAPI CheckDlgButton( HWND hwnd, INT id, UINT check )
1401 {
1402 SendDlgItemMessageW( hwnd, id, BM_SETCHECK, check, 0 );
1403 return TRUE;
1404 }
1405
1406
1407 /***********************************************************************
1408 * IsDlgButtonChecked (USER32.@)
1409 */
1410 UINT WINAPI IsDlgButtonChecked( HWND hwnd, int id )
1411 {
1412 return (UINT)SendDlgItemMessageW( hwnd, id, BM_GETCHECK, 0, 0 );
1413 }
1414
1415
1416 /***********************************************************************
1417 * CheckRB
1418 *
1419 * Callback function used to check/uncheck radio buttons that fall
1420 * within a specific range of IDs.
1421 */
1422 static BOOL CALLBACK CheckRB(HWND hwndChild, LPARAM lParam)
1423 {
1424 LONG lChildID = GetWindowLongPtrW(hwndChild, GWLP_ID);
1425 RADIOGROUP *lpRadioGroup = (RADIOGROUP *) lParam;
1426
1427 if ((lChildID >= lpRadioGroup->firstID) &&
1428 (lChildID <= lpRadioGroup->lastID))
1429 {
1430 if (lChildID == lpRadioGroup->checkID)
1431 {
1432 SendMessageW(hwndChild, BM_SETCHECK, BST_CHECKED, 0);
1433 }
1434 else
1435 {
1436 SendMessageW(hwndChild, BM_SETCHECK, BST_UNCHECKED, 0);
1437 }
1438 }
1439
1440 return TRUE;
1441 }
1442
1443
1444 /***********************************************************************
1445 * CheckRadioButton (USER32.@)
1446 */
1447 BOOL WINAPI CheckRadioButton( HWND hwndDlg, int firstID,
1448 int lastID, int checkID )
1449 {
1450 RADIOGROUP radioGroup;
1451
1452 radioGroup.firstID = firstID;
1453 radioGroup.lastID = lastID;
1454 radioGroup.checkID = checkID;
1455
1456 return EnumChildWindows(hwndDlg, (WNDENUMPROC)CheckRB,
1457 (LPARAM)&radioGroup);
1458 }
1459
1460
1461 /***********************************************************************
1462 * GetDialogBaseUnits (USER.243)
1463 * GetDialogBaseUnits (USER32.@)
1464 */
1465 DWORD WINAPI GetDialogBaseUnits(void)
1466 {
1467 static DWORD units;
1468
1469 if (!units)
1470 {
1471 HDC hdc;
1472 SIZE size;
1473
1474 if ((hdc = GetDC(0)))
1475 {
1476 size.cx = GdiGetCharDimensions( hdc, NULL, &size.cy );
1477 if (size.cx) units = MAKELONG( size.cx, size.cy );
1478 ReleaseDC( 0, hdc );
1479 }
1480 TRACE("base units = %d,%d\n", LOWORD(units), HIWORD(units) );
1481 }
1482 return units;
1483 }
1484
1485
1486 /***********************************************************************
1487 * MapDialogRect (USER32.@)
1488 */
1489 BOOL WINAPI MapDialogRect( HWND hwnd, LPRECT rect )
1490 {
1491 DIALOGINFO * dlgInfo;
1492 if (!(dlgInfo = DIALOG_get_info( hwnd, FALSE ))) return FALSE;
1493 rect->left = MulDiv(rect->left, dlgInfo->xBaseUnit, 4);
1494 rect->right = MulDiv(rect->right, dlgInfo->xBaseUnit, 4);
1495 rect->top = MulDiv(rect->top, dlgInfo->yBaseUnit, 8);
1496 rect->bottom = MulDiv(rect->bottom, dlgInfo->yBaseUnit, 8);
1497 return TRUE;
1498 }
1499
1500
1501 /***********************************************************************
1502 * GetNextDlgGroupItem (USER32.@)
1503 *
1504 * Corrections to MSDN documentation
1505 *
1506 * (Under Windows 2000 at least, where hwndDlg is not actually a dialog)
1507 * 1. hwndCtrl can be hwndDlg in which case it behaves as for NULL
1508 * 2. Prev of NULL or hwndDlg fails
1509 */
1510 HWND WINAPI GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1511 {
1512 HWND hwnd, hwndNext, retvalue, hwndLastGroup = 0;
1513 BOOL fLooped=FALSE;
1514 BOOL fSkipping=FALSE;
1515
1516 hwndDlg = WIN_GetFullHandle( hwndDlg );
1517 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1518
1519 if (hwndDlg == hwndCtrl) hwndCtrl = NULL;
1520 if (!hwndCtrl && fPrevious) return 0;
1521
1522 if (hwndCtrl)
1523 {
1524 if (!IsChild (hwndDlg, hwndCtrl)) return 0;
1525 }
1526 else
1527 {
1528 /* No ctrl specified -> start from the beginning */
1529 if (!(hwndCtrl = GetWindow( hwndDlg, GW_CHILD ))) return 0;
1530 /* MSDN is wrong. fPrevious does not result in the last child */
1531
1532 /* Maybe that first one is valid. If so then we don't want to skip it*/
1533 if ((GetWindowLongW( hwndCtrl, GWL_STYLE ) & (WS_VISIBLE|WS_DISABLED)) == WS_VISIBLE)
1534 {
1535 return hwndCtrl;
1536 }
1537 }
1538
1539 /* Always go forward around the group and list of controls; for the
1540 * previous control keep track; for the next break when you find one
1541 */
1542 retvalue = hwndCtrl;
1543 hwnd = hwndCtrl;
1544 while (hwndNext = GetWindow (hwnd, GW_HWNDNEXT),
1545 1)
1546 {
1547 while (!hwndNext)
1548 {
1549 /* Climb out until there is a next sibling of the ancestor or we
1550 * reach the top (in which case we loop back to the start)
1551 */
1552 if (hwndDlg == GetParent (hwnd))
1553 {
1554 /* Wrap around to the beginning of the list, within the same
1555 * group. (Once only)
1556 */
1557 if (fLooped) goto end;
1558 fLooped = TRUE;
1559 hwndNext = GetWindow (hwndDlg, GW_CHILD);
1560 }
1561 else
1562 {
1563 hwnd = GetParent (hwnd);
1564 hwndNext = GetWindow (hwnd, GW_HWNDNEXT);
1565 }
1566 }
1567 hwnd = hwndNext;
1568
1569 /* Wander down the leading edge of controlparents */
1570 while ( (GetWindowLongW (hwnd, GWL_EXSTYLE) & WS_EX_CONTROLPARENT) &&
1571 ((GetWindowLongW (hwnd, GWL_STYLE) & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE) &&
1572 (hwndNext = GetWindow (hwnd, GW_CHILD)))
1573 hwnd = hwndNext;
1574 /* Question. If the control is a control parent but either has no
1575 * children or is not visible/enabled then if it has a WS_GROUP does
1576 * it count? For that matter does it count anyway?
1577 * I believe it doesn't count.
1578 */
1579
1580 if ((GetWindowLongW (hwnd, GWL_STYLE) & WS_GROUP))
1581 {
1582 hwndLastGroup = hwnd;
1583 if (!fSkipping)
1584 {
1585 /* Look for the beginning of the group */
1586 fSkipping = TRUE;
1587 }
1588 }
1589
1590 if (hwnd == hwndCtrl)
1591 {
1592 if (!fSkipping) break;
1593 if (hwndLastGroup == hwnd) break;
1594 hwnd = hwndLastGroup;
1595 fSkipping = FALSE;
1596 fLooped = FALSE;
1597 }
1598
1599 if (!fSkipping &&
1600 (GetWindowLongW (hwnd, GWL_STYLE) & (WS_VISIBLE|WS_DISABLED)) ==
1601 WS_VISIBLE)
1602 {
1603 retvalue = hwnd;
1604 if (!fPrevious) break;
1605 }
1606 }
1607 end:
1608 return retvalue;
1609 }
1610
1611
1612 /***********************************************************************
1613 * DIALOG_GetNextTabItem
1614 *
1615 * Recursive helper for GetNextDlgTabItem
1616 */
1617 static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
1618 {
1619 LONG dsStyle;
1620 LONG exStyle;
1621 UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
1622 HWND retWnd = 0;
1623 HWND hChildFirst = 0;
1624
1625 if(!hwndCtrl)
1626 {
1627 hChildFirst = GetWindow(hwndDlg,GW_CHILD);
1628 if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
1629 }
1630 else if (IsChild( hwndMain, hwndCtrl ))
1631 {
1632 hChildFirst = GetWindow(hwndCtrl,wndSearch);
1633 if(!hChildFirst)
1634 {
1635 if(GetParent(hwndCtrl) != hwndMain)
1636 /* i.e. if we are not at the top level of the recursion */
1637 hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
1638 else
1639 hChildFirst = GetWindow(hwndCtrl, fPrevious ? GW_HWNDLAST : GW_HWNDFIRST);
1640 }
1641 }
1642
1643 while(hChildFirst)
1644 {
1645 dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
1646 exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
1647 if( (exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1648 {
1649 HWND retWnd;
1650 retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,NULL,fPrevious );
1651 if (retWnd) return (retWnd);
1652 }
1653 else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
1654 {
1655 return (hChildFirst);
1656 }
1657 hChildFirst = GetWindow(hChildFirst,wndSearch);
1658 }
1659 if(hwndCtrl)
1660 {
1661 HWND hParent = GetParent(hwndCtrl);
1662 while(hParent)
1663 {
1664 if(hParent == hwndMain) break;
1665 retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
1666 if(retWnd) break;
1667 hParent = GetParent(hParent);
1668 }
1669 if(!retWnd)
1670 retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,NULL,fPrevious );
1671 }
1672 return retWnd ? retWnd : hwndCtrl;
1673 }
1674
1675 /***********************************************************************
1676 * GetNextDlgTabItem (USER32.@)
1677 */
1678 HWND WINAPI GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl,
1679 BOOL fPrevious )
1680 {
1681 hwndDlg = WIN_GetFullHandle( hwndDlg );
1682 hwndCtrl = WIN_GetFullHandle( hwndCtrl );
1683
1684 /* Undocumented but tested under Win2000 and WinME */
1685 if (hwndDlg == hwndCtrl) hwndCtrl = NULL;
1686
1687 /* Contrary to MSDN documentation, tested under Win2000 and WinME
1688 * NB GetLastError returns whatever was set before the function was
1689 * called.
1690 */
1691 if (!hwndCtrl && fPrevious) return 0;
1692
1693 return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious);
1694 }
1695
1696 /**********************************************************************
1697 * DIALOG_DlgDirSelect
1698 *
1699 * Helper function for DlgDirSelect*
1700 */
1701 static BOOL DIALOG_DlgDirSelect( HWND hwnd, LPWSTR str, INT len,
1702 INT id, BOOL unicode, BOOL combo )
1703 {
1704 WCHAR *buffer, *ptr;
1705 INT item, size;
1706 BOOL ret;
1707 HWND listbox = GetDlgItem( hwnd, id );
1708
1709 TRACE("%p %s %d\n", hwnd, unicode ? debugstr_w(str) : debugstr_a((LPSTR)str), id );
1710 if (!listbox) return FALSE;
1711
1712 item = SendMessageW(listbox, combo ? CB_GETCURSEL : LB_GETCURSEL, 0, 0 );
1713 if (item == LB_ERR) return FALSE;
1714
1715 size = SendMessageW(listbox, combo ? CB_GETLBTEXTLEN : LB_GETTEXTLEN, item, 0 );
1716 if (size == LB_ERR) return FALSE;
1717
1718 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, (size+2) * sizeof(WCHAR) ))) return FALSE;
1719
1720 SendMessageW( listbox, combo ? CB_GETLBTEXT : LB_GETTEXT, item, (LPARAM)buffer );
1721
1722 if ((ret = (buffer[0] == '['))) /* drive or directory */
1723 {
1724 if (buffer[1] == '-') /* drive */
1725 {
1726 buffer[3] = ':';
1727 buffer[4] = 0;
1728 ptr = buffer + 2;
1729 }
1730 else
1731 {
1732 buffer[strlenW(buffer)-1] = '\\';
1733 ptr = buffer + 1;
1734 }
1735 }
1736 else
1737 {
1738 /* Filenames without a dot extension must have one tacked at the end */
1739 if (strchrW(buffer, '.') == NULL)
1740 {
1741 buffer[strlenW(buffer)+1] = '\0';
1742 buffer[strlenW(buffer)] = '.';
1743 }
1744 ptr = buffer;
1745 }
1746
1747 if (!unicode)
1748 {
1749 if (len > 0 && !WideCharToMultiByte( CP_ACP, 0, ptr, -1, (LPSTR)str, len, 0, 0 ))
1750 ((LPSTR)str)[len-1] = 0;
1751 }
1752 else lstrcpynW( str, ptr, len );
1753 HeapFree( GetProcessHeap(), 0, buffer );
1754 TRACE("Returning %d %s\n", ret, unicode ? debugstr_w(str) : debugstr_a((LPSTR)str) );
1755 return ret;
1756 }
1757
1758
1759 /**********************************************************************
1760 * DIALOG_DlgDirListW
1761 *
1762 * Helper function for DlgDirList*W
1763 */
1764 static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
1765 INT idStatic, UINT attrib, BOOL combo )
1766 {
1767 HWND hwnd;
1768 LPWSTR orig_spec = spec;
1769 WCHAR any[] = {'*','.','*',0};
1770
1771 #define SENDMSG(msg,wparam,lparam) \
1772 ((attrib & DDL_POSTMSGS) ? PostMessageW( hwnd, msg, wparam, lparam ) \
1773 : SendMessageW( hwnd, msg, wparam, lparam ))
1774
1775 TRACE("%p %s %d %d %04x\n", hDlg, debugstr_w(spec), idLBox, idStatic, attrib );
1776
1777 /* If the path exists and is a directory, chdir to it */
1778 if (!spec || !spec[0] || SetCurrentDirectoryW( spec )) spec = any;
1779 else
1780 {
1781 WCHAR *p, *p2;
1782 p = spec;
1783 if ((p2 = strchrW( p, ':' ))) p = p2 + 1;
1784 if ((p2 = strrchrW( p, '\\' ))) p = p2;
1785 if ((p2 = strrchrW( p, '/' ))) p = p2;
1786 if (p != spec)
1787 {
1788 WCHAR sep = *p;
1789 *p = 0;
1790 if (!SetCurrentDirectoryW( spec ))
1791 {
1792 *p = sep; /* Restore the original spec */
1793 return FALSE;
1794 }
1795 spec = p + 1;
1796 }
1797 }
1798
1799 TRACE( "mask=%s\n", debugstr_w(spec) );
1800
1801 if (idLBox && ((hwnd = GetDlgItem( hDlg, idLBox )) != 0))
1802 {
1803 if (attrib == DDL_DRIVES) attrib |= DDL_EXCLUSIVE;
1804
1805 SENDMSG( combo ? CB_RESETCONTENT : LB_RESETCONTENT, 0, 0 );
1806 if (attrib & DDL_DIRECTORY)
1807 {
1808 if (!(attrib & DDL_EXCLUSIVE))
1809 {
1810 SENDMSG( combo ? CB_DIR : LB_DIR,
1811 attrib & ~(DDL_DIRECTORY | DDL_DRIVES),
1812 (LPARAM)spec );
1813 }
1814 SENDMSG( combo ? CB_DIR : LB_DIR,
1815 (attrib & (DDL_DIRECTORY | DDL_DRIVES)) | DDL_EXCLUSIVE,
1816 (LPARAM)any );
1817 }
1818 else
1819 {
1820 SENDMSG( combo ? CB_DIR : LB_DIR, attrib, (LPARAM)spec );
1821 }
1822 }
1823
1824 /* Convert path specification to uppercase */
1825 if (spec) CharUpperW(spec);
1826
1827 if (idStatic && ((hwnd = GetDlgItem( hDlg, idStatic )) != 0))
1828 {
1829 WCHAR temp[MAX_PATH];
1830 GetCurrentDirectoryW( sizeof(temp)/sizeof(WCHAR), temp );
1831 CharLowerW( temp );
1832 /* Can't use PostMessage() here, because the string is on the stack */
1833 SetDlgItemTextW( hDlg, idStatic, temp );
1834 }
1835
1836 if (orig_spec && (spec != orig_spec))
1837 {
1838 /* Update the original file spec */
1839 WCHAR *p = spec;
1840 while ((*orig_spec++ = *p++));
1841 }
1842
1843 return TRUE;
1844 #undef SENDMSG
1845 }
1846
1847
1848 /**********************************************************************
1849 * DIALOG_DlgDirListA
1850 *
1851 * Helper function for DlgDirList*A
1852 */
1853 static INT DIALOG_DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
1854 INT idStatic, UINT attrib, BOOL combo )
1855 {
1856 if (spec)
1857 {
1858 INT ret, len = MultiByteToWideChar( CP_ACP, 0, spec, -1, NULL, 0 );
1859 LPWSTR specW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1860 MultiByteToWideChar( CP_ACP, 0, spec, -1, specW, len );
1861 ret = DIALOG_DlgDirListW( hDlg, specW, idLBox, idStatic, attrib, combo );
1862 WideCharToMultiByte( CP_ACP, 0, specW, -1, spec, 0x7fffffff, NULL, NULL );
1863 HeapFree( GetProcessHeap(), 0, specW );
1864 return ret;
1865 }
1866 return DIALOG_DlgDirListW( hDlg, NULL, idLBox, idStatic, attrib, combo );
1867 }
1868
1869
1870 /**********************************************************************
1871 * DlgDirSelectExA (USER32.@)
1872 */
1873 BOOL WINAPI DlgDirSelectExA( HWND hwnd, LPSTR str, INT len, INT id )
1874 {
1875 return DIALOG_DlgDirSelect( hwnd, (LPWSTR)str, len, id, FALSE, FALSE );
1876 }
1877
1878
1879 /**********************************************************************
1880 * DlgDirSelectExW (USER32.@)
1881 */
1882 BOOL WINAPI DlgDirSelectExW( HWND hwnd, LPWSTR str, INT len, INT id )
1883 {
1884 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, FALSE );
1885 }
1886
1887
1888 /**********************************************************************
1889 * DlgDirSelectComboBoxExA (USER32.@)
1890 */
1891 BOOL WINAPI DlgDirSelectComboBoxExA( HWND hwnd, LPSTR str, INT len,
1892 INT id )
1893 {
1894 return DIALOG_DlgDirSelect( hwnd, (LPWSTR)str, len, id, FALSE, TRUE );
1895 }
1896
1897
1898 /**********************************************************************
1899 * DlgDirSelectComboBoxExW (USER32.@)
1900 */
1901 BOOL WINAPI DlgDirSelectComboBoxExW( HWND hwnd, LPWSTR str, INT len,
1902 INT id)
1903 {
1904 return DIALOG_DlgDirSelect( hwnd, str, len, id, TRUE, TRUE );
1905 }
1906
1907
1908 /**********************************************************************
1909 * DlgDirListA (USER32.@)
1910 */
1911 INT WINAPI DlgDirListA( HWND hDlg, LPSTR spec, INT idLBox,
1912 INT idStatic, UINT attrib )
1913 {
1914 return DIALOG_DlgDirListA( hDlg, spec, idLBox, idStatic, attrib, FALSE );
1915 }
1916
1917
1918 /**********************************************************************
1919 * DlgDirListW (USER32.@)
1920 */
1921 INT WINAPI DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
1922 INT idStatic, UINT attrib )
1923 {
1924 return DIALOG_DlgDirListW( hDlg, spec, idLBox, idStatic, attrib, FALSE );
1925 }
1926
1927
1928 /**********************************************************************
1929 * DlgDirListComboBoxA (USER32.@)
1930 */
1931 INT WINAPI DlgDirListComboBoxA( HWND hDlg, LPSTR spec, INT idCBox,
1932 INT idStatic, UINT attrib )
1933 {
1934 return DIALOG_DlgDirListA( hDlg, spec, idCBox, idStatic, attrib, TRUE );
1935 }
1936
1937
1938 /**********************************************************************
1939 * DlgDirListComboBoxW (USER32.@)
1940 */
1941 INT WINAPI DlgDirListComboBoxW( HWND hDlg, LPWSTR spec, INT idCBox,
1942 INT idStatic, UINT attrib )
1943 {
1944 return DIALOG_DlgDirListW( hDlg, spec, idCBox, idStatic, attrib, TRUE );
1945 }
1946
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.