4 * Copyright 1993, 1994, 1996 Alexandre Julliard
17 #include "wine/winuser16.h"
18 #include "wine/winbase16.h"
19 #include "wine/unicode.h"
20 #include "wine/winestring.h"
30 #include "debugtools.h"
32 DEFAULT_DEBUG_CHANNEL(dialog
);
35 /* Dialog control information */
72 /* Radio button group */
80 /* Dialog base units */
81 static WORD xBaseUnit
= 0, yBaseUnit
= 0;
84 /***********************************************************************
87 * Helper function for modal dialogs to enable again the
88 * owner of the dialog box.
90 void DIALOG_EnableOwner( HWND hOwner
, BOOL ownerWasEnabled
)
92 /* Owner must be a top-level window */
94 hOwner
= WIN_GetTopParent( hOwner
);
97 EnableWindow( hOwner
, TRUE
);
101 /***********************************************************************
102 * DIALOG_DisableOwner
104 * Helper function for modal dialogs to disable the
105 * owner of the dialog box. Returns TRUE if owner was enabled.
107 BOOL
DIALOG_DisableOwner( HWND hOwner
)
109 /* Owner must be a top-level window */
111 hOwner
= WIN_GetTopParent( hOwner
);
112 if (!hOwner
) return FALSE
;
113 if (IsWindowEnabled( hOwner
))
115 EnableWindow( hOwner
, FALSE
);
122 /***********************************************************************
123 * DIALOG_GetCharSizeFromDC
126 * Calculates the *true* average size of English characters in the
127 * specified font as oppposed to the one returned by GetTextMetrics.
129 * Latest: the X font driver will now compute a proper average width
130 * so this code can be removed
132 static BOOL
DIALOG_GetCharSizeFromDC( HDC hDC
, HFONT hFont
, SIZE
* pSize
)
134 BOOL Success
= FALSE
;
136 pSize
->cx
= xBaseUnit
;
137 pSize
->cy
= yBaseUnit
;
140 /* select the font */
142 memset(&tm
,0,sizeof(tm
));
143 if (hFont
) hFontPrev
= SelectFont(hDC
,hFont
);
144 if (GetTextMetricsA(hDC
,&tm
))
146 pSize
->cx
= tm
.tmAveCharWidth
;
147 pSize
->cy
= tm
.tmHeight
;
149 /* if variable width font */
150 if (tm
.tmPitchAndFamily
& TMPF_FIXED_PITCH
)
153 const char* szAvgChars
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
155 /* Calculate a true average as opposed to the one returned
156 * by tmAveCharWidth. This works better when dealing with
157 * proportional spaced fonts and (more important) that's
158 * how Microsoft's dialog creation code calculates the size
161 if (GetTextExtentPointA(hDC
,szAvgChars
,sizeof(szAvgChars
),&total
))
164 pSize
->cx
= ((2*total
.cx
/sizeof(szAvgChars
)) + 1)/2;
172 /* Use the text metrics */
173 TRACE("Using tm: %ldx%ld (dlg: %ld x %ld) (%s)\n",
174 tm
.tmAveCharWidth
, tm
.tmHeight
, pSize
->cx
, pSize
->cy
,
175 tm
.tmPitchAndFamily
& TMPF_FIXED_PITCH
? "variable" : "fixed");
176 pSize
->cx
= tm
.tmAveCharWidth
;
177 pSize
->cy
= tm
.tmHeight
;
179 /* select the original font */
180 if (hFontPrev
) SelectFont(hDC
,hFontPrev
);
185 /***********************************************************************
188 * A convenient variant of DIALOG_GetCharSizeFromDC.
190 static BOOL
DIALOG_GetCharSize( HFONT hFont
, SIZE
* pSize
)
193 BOOL Success
= DIALOG_GetCharSizeFromDC( hDC
, hFont
, pSize
);
198 /***********************************************************************
201 * Initialisation of the dialog manager.
203 BOOL
DIALOG_Init(void)
208 /* Calculate the dialog base units */
210 if (!(hdc
= CreateDCA( "DISPLAY", NULL
, NULL
, NULL
)))
212 ERR("Could not create Display DC\n");
216 if (!DIALOG_GetCharSizeFromDC( hdc
, 0, &size
))
219 ERR("Could not initialize base dialog units\n");
227 TRACE("base units = %d,%d\n", xBaseUnit
, yBaseUnit
);
232 /***********************************************************************
233 * DIALOG_GetControl16
235 * Return the class and text of the control pointed to by ptr,
236 * fill the header structure and return a pointer to the next control.
238 static LPCSTR
DIALOG_GetControl16( LPCSTR p
, DLG_CONTROL_INFO
*info
)
240 static char buffer
[10];
243 info
->x
= GET_WORD(p
); p
+= sizeof(WORD
);
244 info
->y
= GET_WORD(p
); p
+= sizeof(WORD
);
245 info
->cx
= GET_WORD(p
); p
+= sizeof(WORD
);
246 info
->cy
= GET_WORD(p
); p
+= sizeof(WORD
);
247 info
->id
= GET_WORD(p
); p
+= sizeof(WORD
);
248 info
->style
= GET_DWORD(p
); p
+= sizeof(DWORD
);
255 case 0x80: strcpy( buffer
, "BUTTON" ); break;
256 case 0x81: strcpy( buffer
, "EDIT" ); break;
257 case 0x82: strcpy( buffer
, "STATIC" ); break;
258 case 0x83: strcpy( buffer
, "LISTBOX" ); break;
259 case 0x84: strcpy( buffer
, "SCROLLBAR" ); break;
260 case 0x85: strcpy( buffer
, "COMBOBOX" ); break;
261 default: buffer
[0] = '\0'; break;
263 info
->className
= buffer
;
272 int_id
= ((BYTE
)*p
== 0xff);
275 /* Integer id, not documented (?). Only works for SS_ICON controls */
276 info
->windowName
= (LPCSTR
)(UINT
)GET_WORD(p
+1);
281 info
->windowName
= p
;
287 /* Additional CTLDATA available for this control. */
288 info
->data
= SEGPTR_ALLOC(*p
);
289 memcpy( info
->data
, p
+ 1, *p
);
291 else info
->data
= NULL
;
296 TRACE(" %s %04x %d, %d, %d, %d, %d, %08lx, %08lx\n",
297 info
->className
, LOWORD(info
->windowName
),
298 info
->id
, info
->x
, info
->y
, info
->cx
, info
->cy
,
299 info
->style
, (DWORD
)SEGPTR_GET(info
->data
) );
301 TRACE(" %s '%s' %d, %d, %d, %d, %d, %08lx, %08lx\n",
302 info
->className
, info
->windowName
,
303 info
->id
, info
->x
, info
->y
, info
->cx
, info
->cy
,
304 info
->style
, (DWORD
)SEGPTR_GET(info
->data
) );
310 /***********************************************************************
311 * DIALOG_GetControl32
313 * Return the class and text of the control pointed to by ptr,
314 * fill the header structure and return a pointer to the next control.
316 static const WORD
*DIALOG_GetControl32( const WORD
*p
, DLG_CONTROL_INFO
*info
,
321 info
->helpId
= GET_DWORD(p
); p
+= 2;
322 info
->exStyle
= GET_DWORD(p
); p
+= 2;
323 info
->style
= GET_DWORD(p
); p
+= 2;
328 info
->style
= GET_DWORD(p
); p
+= 2;
329 info
->exStyle
= GET_DWORD(p
); p
+= 2;
331 info
->x
= GET_WORD(p
); p
++;
332 info
->y
= GET_WORD(p
); p
++;
333 info
->cx
= GET_WORD(p
); p
++;
334 info
->cy
= GET_WORD(p
); p
++;
338 /* id is a DWORD for DIALOGEX */
339 info
->id
= GET_DWORD(p
);
344 info
->id
= GET_WORD(p
);
348 if (GET_WORD(p
) == 0xffff)
350 static const WCHAR class_names
[6][10] =
352 { 'B','u','t','t','o','n', }, /* 0x80 */
353 { 'E','d','i','t', }, /* 0x81 */
354 { 'S','t','a','t','i','c', }, /* 0x82 */
355 { 'L','i','s','t','B','o','x', }, /* 0x83 */
356 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
357 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
359 WORD id
= GET_WORD(p
+1);
360 if ((id
>= 0x80) && (id
<= 0x85))
361 info
->className
= (LPCSTR
)class_names
[id
- 0x80];
364 info
->className
= NULL
;
365 ERR("Unknown built-in class id %04x\n", id
);
371 info
->className
= (LPCSTR
)p
;
372 p
+= strlenW( (LPCWSTR
)p
) + 1;
375 if (GET_WORD(p
) == 0xffff) /* Is it an integer id? */
377 info
->windowName
= (LPCSTR
)(UINT
)GET_WORD(p
+ 1);
382 info
->windowName
= (LPCSTR
)p
;
383 p
+= strlenW( (LPCWSTR
)p
) + 1;
386 TRACE(" %s %s %d, %d, %d, %d, %d, %08lx, %08lx, %08lx\n",
387 debugstr_w( (LPCWSTR
)info
->className
),
388 debugres_w( (LPCWSTR
)info
->windowName
),
389 info
->id
, info
->x
, info
->y
, info
->cx
, info
->cy
,
390 info
->style
, info
->exStyle
, info
->helpId
);
394 if (TRACE_ON(dialog
))
396 WORD i
, count
= GET_WORD(p
) / sizeof(WORD
);
399 for (i
= 0; i
< count
; i
++) DPRINTF( "%04x,", GET_WORD(p
+i
+1) );
403 info
->data
= (LPVOID
)(p
+ 1);
404 p
+= GET_WORD(p
) / sizeof(WORD
);
406 else info
->data
= NULL
;
409 /* Next control is on dword boundary */
410 return (const WORD
*)((((int)p
) + 3) & ~3);
414 /***********************************************************************
415 * DIALOG_CreateControls
417 * Create the control windows for a dialog.
419 static BOOL
DIALOG_CreateControls( WND
*pWnd
, LPCSTR
template,
420 const DLG_TEMPLATE
*dlgTemplate
,
421 HINSTANCE hInst
, BOOL win32
)
423 DIALOGINFO
*dlgInfo
= (DIALOGINFO
*)pWnd
->wExtra
;
424 DLG_CONTROL_INFO info
;
425 HWND hwndCtrl
, hwndDefButton
= 0;
426 INT items
= dlgTemplate
->nbItems
;
433 HINSTANCE16 instance
;
434 template = DIALOG_GetControl16( template, &info
);
435 if (HIWORD(info
.className
) && !strcmp( info
.className
, "EDIT") &&
436 ((pWnd
->dwStyle
& DS_LOCALEDIT
) != DS_LOCALEDIT
))
438 if (!dlgInfo
->hDialogHeap
)
440 dlgInfo
->hDialogHeap
= GlobalAlloc16(GMEM_FIXED
, 0x10000);
441 if (!dlgInfo
->hDialogHeap
)
443 ERR("Insufficient memory to create heap for edit control\n" );
446 LocalInit16(dlgInfo
->hDialogHeap
, 0, 0xffff);
448 instance
= dlgInfo
->hDialogHeap
;
450 else instance
= (HINSTANCE16
)hInst
;
452 hwndCtrl
= CreateWindowEx16( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
453 info
.className
, info
.windowName
,
454 info
.style
| WS_CHILD
,
455 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
456 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
457 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
458 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
459 pWnd
->hwndSelf
, (HMENU16
)info
.id
,
460 instance
, (LPVOID
)SEGPTR_GET(info
.data
) );
462 if (info
.data
) SEGPTR_FREE(info
.data
);
466 template = (LPCSTR
)DIALOG_GetControl32( (WORD
*)template, &info
,
467 dlgTemplate
->dialogEx
);
468 hwndCtrl
= CreateWindowExW( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
469 (LPCWSTR
)info
.className
,
470 (LPCWSTR
)info
.windowName
,
471 info
.style
| WS_CHILD
,
472 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
473 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
474 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
475 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
476 pWnd
->hwndSelf
, (HMENU
)info
.id
,
479 if (!hwndCtrl
) return FALSE
;
481 /* Send initialisation messages to the control */
482 if (dlgInfo
->hUserFont
) SendMessageA( hwndCtrl
, WM_SETFONT
,
483 (WPARAM
)dlgInfo
->hUserFont
, 0 );
484 if (SendMessageA(hwndCtrl
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
)
486 /* If there's already a default push-button, set it back */
487 /* to normal and use this one instead. */
489 SendMessageA( hwndDefButton
, BM_SETSTYLE
,
490 BS_PUSHBUTTON
,FALSE
);
491 hwndDefButton
= hwndCtrl
;
492 dlgInfo
->idResult
= GetWindowWord( hwndCtrl
, GWW_ID
);
500 /***********************************************************************
501 * DIALOG_ParseTemplate16
503 * Fill a DLG_TEMPLATE structure from the dialog template, and return
504 * a pointer to the first control.
506 static LPCSTR
DIALOG_ParseTemplate16( LPCSTR p
, DLG_TEMPLATE
* result
)
508 result
->style
= GET_DWORD(p
); p
+= sizeof(DWORD
);
510 result
->nbItems
= (unsigned char) *p
++;
511 result
->x
= GET_WORD(p
); p
+= sizeof(WORD
);
512 result
->y
= GET_WORD(p
); p
+= sizeof(WORD
);
513 result
->cx
= GET_WORD(p
); p
+= sizeof(WORD
);
514 result
->cy
= GET_WORD(p
); p
+= sizeof(WORD
);
515 TRACE("DIALOG %d, %d, %d, %d\n",
516 result
->x
, result
->y
, result
->cx
, result
->cy
);
517 TRACE(" STYLE %08lx\n", result
->style
);
519 /* Get the menu name */
524 result
->menuName
= 0;
528 result
->menuName
= (LPCSTR
)(UINT
)GET_WORD( p
+ 1 );
530 TRACE(" MENU %04x\n", LOWORD(result
->menuName
) );
533 result
->menuName
= p
;
534 TRACE(" MENU '%s'\n", p
);
539 /* Get the class name */
543 result
->className
= p
;
544 TRACE(" CLASS '%s'\n", result
->className
);
546 else result
->className
= DIALOG_CLASS_ATOM
;
549 /* Get the window caption */
553 TRACE(" CAPTION '%s'\n", result
->caption
);
555 /* Get the font name */
557 if (result
->style
& DS_SETFONT
)
559 result
->pointSize
= GET_WORD(p
);
561 result
->faceName
= p
;
563 TRACE(" FONT %d,'%s'\n",
564 result
->pointSize
, result
->faceName
);
570 /***********************************************************************
571 * DIALOG_ParseTemplate32
573 * Fill a DLG_TEMPLATE structure from the dialog template, and return
574 * a pointer to the first control.
576 static LPCSTR
DIALOG_ParseTemplate32( LPCSTR
template, DLG_TEMPLATE
* result
)
578 const WORD
*p
= (const WORD
*)template;
580 result
->style
= GET_DWORD(p
); p
+= 2;
581 if (result
->style
== 0xffff0001) /* DIALOGEX resource */
583 result
->dialogEx
= TRUE
;
584 result
->helpId
= GET_DWORD(p
); p
+= 2;
585 result
->exStyle
= GET_DWORD(p
); p
+= 2;
586 result
->style
= GET_DWORD(p
); p
+= 2;
590 result
->dialogEx
= FALSE
;
592 result
->exStyle
= GET_DWORD(p
); p
+= 2;
594 result
->nbItems
= GET_WORD(p
); p
++;
595 result
->x
= GET_WORD(p
); p
++;
596 result
->y
= GET_WORD(p
); p
++;
597 result
->cx
= GET_WORD(p
); p
++;
598 result
->cy
= GET_WORD(p
); p
++;
599 TRACE("DIALOG%s %d, %d, %d, %d, %ld\n",
600 result
->dialogEx
? "EX" : "", result
->x
, result
->y
,
601 result
->cx
, result
->cy
, result
->helpId
);
602 TRACE(" STYLE 0x%08lx\n", result
->style
);
603 TRACE(" EXSTYLE 0x%08lx\n", result
->exStyle
);
605 /* Get the menu name */
610 result
->menuName
= NULL
;
614 result
->menuName
= (LPCSTR
)(UINT
)GET_WORD( p
+ 1 );
616 TRACE(" MENU %04x\n", LOWORD(result
->menuName
) );
619 result
->menuName
= (LPCSTR
)p
;
620 TRACE(" MENU %s\n", debugstr_w( (LPCWSTR
)p
));
621 p
+= strlenW( (LPCWSTR
)p
) + 1;
625 /* Get the class name */
630 result
->className
= DIALOG_CLASS_ATOM
;
634 result
->className
= (LPCSTR
)(UINT
)GET_WORD( p
+ 1 );
636 TRACE(" CLASS %04x\n", LOWORD(result
->className
) );
639 result
->className
= (LPCSTR
)p
;
640 TRACE(" CLASS %s\n", debugstr_w( (LPCWSTR
)p
));
641 p
+= strlenW( (LPCWSTR
)p
) + 1;
645 /* Get the window caption */
647 result
->caption
= (LPCSTR
)p
;
648 p
+= strlenW( (LPCWSTR
)p
) + 1;
649 TRACE(" CAPTION %s\n", debugstr_w( (LPCWSTR
)result
->caption
) );
651 /* Get the font name */
653 if (result
->style
& DS_SETFONT
)
655 result
->pointSize
= GET_WORD(p
);
657 if (result
->dialogEx
)
659 result
->weight
= GET_WORD(p
); p
++;
660 result
->italic
= LOBYTE(GET_WORD(p
)); p
++;
664 result
->weight
= FW_DONTCARE
;
665 result
->italic
= FALSE
;
667 result
->faceName
= (LPCSTR
)p
;
668 p
+= strlenW( (LPCWSTR
)p
) + 1;
669 TRACE(" FONT %d, %s, %d, %s\n",
670 result
->pointSize
, debugstr_w( (LPCWSTR
)result
->faceName
),
671 result
->weight
, result
->italic
? "TRUE" : "FALSE" );
674 /* First control is on dword boundary */
675 return (LPCSTR
)((((int)p
) + 3) & ~3);
679 /***********************************************************************
680 * DIALOG_CreateIndirect
681 * Creates a dialog box window
683 * modal = TRUE if we are called from a modal dialog box.
684 * (it's more compatible to do it here, as under Windows the owner
685 * is never disabled if the dialog fails because of an invalid template)
687 static HWND
DIALOG_CreateIndirect( HINSTANCE hInst
, LPCSTR dlgTemplate
,
688 BOOL win32Template
, HWND owner
,
689 DLGPROC16 dlgProc
, LPARAM param
,
690 WINDOWPROCTYPE procType
, BOOL modal
)
697 DLG_TEMPLATE
template;
698 DIALOGINFO
* dlgInfo
;
699 WORD xUnit
= xBaseUnit
;
700 WORD yUnit
= yBaseUnit
;
701 BOOL ownerEnabled
= TRUE
;
703 /* Parse dialog template */
705 if (!dlgTemplate
) return 0;
707 dlgTemplate
= DIALOG_ParseTemplate32( dlgTemplate
, &template );
709 dlgTemplate
= DIALOG_ParseTemplate16( dlgTemplate
, &template );
713 if (template.menuName
)
717 LPSTR str
= SEGPTR_STRDUP( template.menuName
);
718 hMenu
= LoadMenu16( hInst
, SEGPTR_GET(str
) );
721 else hMenu
= LoadMenuW( hInst
, (LPCWSTR
)template.menuName
);
724 /* Create custom font if needed */
726 if (template.style
& DS_SETFONT
)
728 /* The font height must be negative as it is a point size */
729 /* and must be converted to pixels first */
730 /* (see CreateFont() documentation in the Windows SDK). */
732 int pixels
= template.pointSize
* GetDeviceCaps(dc
, LOGPIXELSY
)/72;
736 hFont
= CreateFontW( -pixels
, 0, 0, 0, template.weight
,
737 template.italic
, FALSE
, FALSE
,
738 DEFAULT_CHARSET
, 0, 0,
739 PROOF_QUALITY
, FF_DONTCARE
,
740 (LPCWSTR
)template.faceName
);
742 hFont
= CreateFontA( -pixels
, 0, 0, 0, FW_DONTCARE
,
744 DEFAULT_CHARSET
, 0, 0,
745 PROOF_QUALITY
, FF_DONTCARE
,
750 if (DIALOG_GetCharSize(hFont
,&charSize
))
756 TRACE("units = %d,%d\n", xUnit
, yUnit
);
759 /* Create dialog main window */
761 rect
.left
= rect
.top
= 0;
762 rect
.right
= MulDiv(template.cx
, xUnit
, 4);
763 rect
.bottom
= MulDiv(template.cy
, yUnit
, 8);
764 if (template.style
& DS_MODALFRAME
)
765 template.exStyle
|= WS_EX_DLGMODALFRAME
;
766 AdjustWindowRectEx( &rect
, template.style
,
767 hMenu
? TRUE
: FALSE
, template.exStyle
);
768 rect
.right
-= rect
.left
;
769 rect
.bottom
-= rect
.top
;
771 if ((INT16
)template.x
== CW_USEDEFAULT16
)
773 rect
.left
= rect
.top
= win32Template
? CW_USEDEFAULT
: CW_USEDEFAULT16
;
777 if (template.style
& DS_CENTER
)
779 rect
.left
= (GetSystemMetrics(SM_CXSCREEN
) - rect
.right
) / 2;
780 rect
.top
= (GetSystemMetrics(SM_CYSCREEN
) - rect
.bottom
) / 2;
784 rect
.left
+= MulDiv(template.x
, xUnit
, 4);
785 rect
.top
+= MulDiv(template.y
, yUnit
, 8);
787 if ( !(template.style
& WS_CHILD
) )
791 if( !(template.style
& DS_ABSALIGN
) )
792 ClientToScreen( owner
, (POINT
*)&rect
);
794 /* try to fit it into the desktop */
796 if( (dX
= rect
.left
+ rect
.right
+ GetSystemMetrics(SM_CXDLGFRAME
)
797 - GetSystemMetrics(SM_CXSCREEN
)) > 0 ) rect
.left
-= dX
;
798 if( (dY
= rect
.top
+ rect
.bottom
+ GetSystemMetrics(SM_CYDLGFRAME
)
799 - GetSystemMetrics(SM_CYSCREEN
)) > 0 ) rect
.top
-= dY
;
800 if( rect
.left
< 0 ) rect
.left
= 0;
801 if( rect
.top
< 0 ) rect
.top
= 0;
806 ownerEnabled
= DIALOG_DisableOwner( owner
);
809 hwnd
= CreateWindowEx16(template.exStyle
, template.className
,
810 template.caption
, template.style
& ~WS_VISIBLE
,
811 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
812 owner
, hMenu
, hInst
, NULL
);
814 hwnd
= CreateWindowExW(template.exStyle
, (LPCWSTR
)template.className
,
815 (LPCWSTR
)template.caption
,
816 template.style
& ~WS_VISIBLE
,
817 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
818 owner
, hMenu
, hInst
, NULL
);
822 if (hFont
) DeleteObject( hFont
);
823 if (hMenu
) DestroyMenu( hMenu
);
825 DIALOG_EnableOwner(owner
, ownerEnabled
);
828 wndPtr
= WIN_FindWndPtr( hwnd
);
829 wndPtr
->flags
|= WIN_ISDIALOG
;
830 wndPtr
->helpContext
= template.helpId
;
832 /* Initialise dialog extra data */
834 dlgInfo
= (DIALOGINFO
*)wndPtr
->wExtra
;
835 WINPROC_SetProc( &dlgInfo
->dlgProc
, (WNDPROC16
)dlgProc
, procType
, WIN_PROC_WINDOW
);
836 dlgInfo
->hUserFont
= hFont
;
837 dlgInfo
->hMenu
= hMenu
;
838 dlgInfo
->xBaseUnit
= xUnit
;
839 dlgInfo
->yBaseUnit
= yUnit
;
840 dlgInfo
->msgResult
= 0;
841 dlgInfo
->idResult
= 0;
842 dlgInfo
->flags
= ownerEnabled
? DF_OWNERENABLED
: 0;
843 dlgInfo
->hDialogHeap
= 0;
845 if (dlgInfo
->hUserFont
)
846 SendMessageA( hwnd
, WM_SETFONT
, (WPARAM
)dlgInfo
->hUserFont
, 0 );
848 /* Create controls */
850 if (DIALOG_CreateControls( wndPtr
, dlgTemplate
, &template,
851 hInst
, win32Template
))
853 HWND hwndPreInitFocus
;
855 /* Send initialisation messages and set focus */
857 dlgInfo
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
859 hwndPreInitFocus
= GetFocus();
860 if (SendMessageA( hwnd
, WM_INITDIALOG
, (WPARAM
)dlgInfo
->hwndFocus
, param
))
862 /* check where the focus is again,
863 * some controls status might have changed in WM_INITDIALOG */
864 dlgInfo
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
865 SetFocus( dlgInfo
->hwndFocus
);
869 /* If the dlgproc has returned FALSE (indicating handling of keyboard focus)
870 but the focus has not changed, set the focus where we expect it. */
871 if ( (wndPtr
->dwStyle
& WS_VISIBLE
) && ( GetFocus() == hwndPreInitFocus
) )
873 dlgInfo
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
874 SetFocus( dlgInfo
->hwndFocus
);
878 if (template.style
& WS_VISIBLE
&& !(wndPtr
->dwStyle
& WS_VISIBLE
))
880 ShowWindow( hwnd
, SW_SHOWNORMAL
); /* SW_SHOW doesn't always work */
882 WIN_ReleaseWndPtr(wndPtr
);
885 WIN_ReleaseWndPtr(wndPtr
);
886 if( IsWindow(hwnd
) ) DestroyWindow( hwnd
);
888 DIALOG_EnableOwner(owner
, ownerEnabled
);
893 /***********************************************************************
894 * CreateDialog16 (USER.89)
896 HWND16 WINAPI
CreateDialog16( HINSTANCE16 hInst
, SEGPTR dlgTemplate
,
897 HWND16 owner
, DLGPROC16 dlgProc
)
899 return CreateDialogParam16( hInst
, dlgTemplate
, owner
, dlgProc
, 0 );
903 /***********************************************************************
904 * CreateDialogParam16 (USER.241)
906 HWND16 WINAPI
CreateDialogParam16( HINSTANCE16 hInst
, SEGPTR dlgTemplate
,
907 HWND16 owner
, DLGPROC16 dlgProc
,
915 TRACE("%04x,%08lx,%04x,%08lx,%ld\n",
916 hInst
, (DWORD
)dlgTemplate
, owner
, (DWORD
)dlgProc
, param
);
918 if (!(hRsrc
= FindResource16( hInst
, dlgTemplate
, RT_DIALOG16
))) return 0;
919 if (!(hmem
= LoadResource16( hInst
, hRsrc
))) return 0;
920 if (!(data
= LockResource16( hmem
))) hwnd
= 0;
921 else hwnd
= CreateDialogIndirectParam16( hInst
, data
, owner
,
923 FreeResource16( hmem
);
927 /***********************************************************************
928 * CreateDialogParamA (USER32.73)
930 HWND WINAPI
CreateDialogParamA( HINSTANCE hInst
, LPCSTR name
,
931 HWND owner
, DLGPROC dlgProc
,
934 HANDLE hrsrc
= FindResourceA( hInst
, name
, RT_DIALOGA
);
935 if (!hrsrc
) return 0;
936 return CreateDialogIndirectParamA( hInst
,
937 (LPVOID
)LoadResource(hInst
, hrsrc
),
938 owner
, dlgProc
, param
);
942 /***********************************************************************
943 * CreateDialogParamW (USER32.74)
945 HWND WINAPI
CreateDialogParamW( HINSTANCE hInst
, LPCWSTR name
,
946 HWND owner
, DLGPROC dlgProc
,
949 HANDLE hrsrc
= FindResourceW( hInst
, name
, RT_DIALOGW
);
950 if (!hrsrc
) return 0;
951 return CreateDialogIndirectParamW( hInst
,
952 (LPVOID
)LoadResource(hInst
, hrsrc
),
953 owner
, dlgProc
, param
);
957 /***********************************************************************
958 * CreateDialogIndirect16 (USER.219)
960 HWND16 WINAPI
CreateDialogIndirect16( HINSTANCE16 hInst
, LPCVOID dlgTemplate
,
961 HWND16 owner
, DLGPROC16 dlgProc
)
963 return CreateDialogIndirectParam16( hInst
, dlgTemplate
, owner
, dlgProc
, 0);
967 /***********************************************************************
968 * CreateDialogIndirectParam16 (USER.242)
970 HWND16 WINAPI
CreateDialogIndirectParam16( HINSTANCE16 hInst
,
972 HWND16 owner
, DLGPROC16 dlgProc
,
975 return DIALOG_CreateIndirect( hInst
, dlgTemplate
, FALSE
, owner
,
976 dlgProc
, param
, WIN_PROC_16
, FALSE
);
980 /***********************************************************************
981 * CreateDialogIndirectParamA (USER32.69)
983 HWND WINAPI
CreateDialogIndirectParamA( HINSTANCE hInst
,
985 HWND owner
, DLGPROC dlgProc
,
988 return DIALOG_CreateIndirect( hInst
, dlgTemplate
, TRUE
, owner
,
989 (DLGPROC16
)dlgProc
, param
, WIN_PROC_32A
, FALSE
);
992 /***********************************************************************
993 * CreateDialogIndirectParamAorW (USER32.71)
995 HWND WINAPI
CreateDialogIndirectParamAorW( HINSTANCE hInst
,
997 HWND owner
, DLGPROC dlgProc
,
999 { FIXME("assume WIN_PROC_32W\n");
1000 return DIALOG_CreateIndirect( hInst
, dlgTemplate
, TRUE
, owner
,
1001 (DLGPROC16
)dlgProc
, param
, WIN_PROC_32W
, FALSE
);
1004 /***********************************************************************
1005 * CreateDialogIndirectParamW (USER32.72)
1007 HWND WINAPI
CreateDialogIndirectParamW( HINSTANCE hInst
,
1008 LPCVOID dlgTemplate
,
1009 HWND owner
, DLGPROC dlgProc
,
1012 return DIALOG_CreateIndirect( hInst
, dlgTemplate
, TRUE
, owner
,
1013 (DLGPROC16
)dlgProc
, param
, WIN_PROC_32W
, FALSE
);
1017 /***********************************************************************
1018 * DIALOG_DoDialogBox
1020 static INT
DIALOG_DoDialogBox( HWND hwnd
, HWND owner
)
1023 DIALOGINFO
* dlgInfo
;
1026 HWND ownerMsg
= WIN_GetTopParent( owner
);
1028 if (!(wndPtr
= WIN_FindWndPtr( hwnd
))) return -1;
1029 dlgInfo
= (DIALOGINFO
*)wndPtr
->wExtra
;
1031 if (!(dlgInfo
->flags
& DF_END
)) /* was EndDialog called in WM_INITDIALOG ? */
1033 ShowWindow( hwnd
, SW_SHOW
);
1034 while (MSG_InternalGetMessage(QMSG_WIN32A
, &msg
, hwnd
, ownerMsg
, MSGF_DIALOGBOX
,
1035 PM_REMOVE
, !(wndPtr
->dwStyle
& DS_NOIDLEMSG
), NULL
))
1037 if (!IsDialogMessageA( hwnd
, &msg
))
1039 TranslateMessage( &msg
);
1040 DispatchMessageA( &msg
);
1042 if (dlgInfo
->flags
& DF_END
) break;
1045 DIALOG_EnableOwner( owner
, (dlgInfo
->flags
& DF_OWNERENABLED
) );
1046 retval
= dlgInfo
->idResult
;
1047 WIN_ReleaseWndPtr(wndPtr
);
1048 DestroyWindow( hwnd
);
1053 /***********************************************************************
1054 * DialogBox16 (USER.87)
1056 INT16 WINAPI
DialogBox16( HINSTANCE16 hInst
, SEGPTR dlgTemplate
,
1057 HWND16 owner
, DLGPROC16 dlgProc
)
1059 return DialogBoxParam16( hInst
, dlgTemplate
, owner
, dlgProc
, 0 );
1063 /***********************************************************************
1064 * DialogBoxParam16 (USER.239)
1066 INT16 WINAPI
DialogBoxParam16( HINSTANCE16 hInst
, SEGPTR
template,
1067 HWND16 owner
, DLGPROC16 dlgProc
, LPARAM param
)
1075 if (!(hRsrc
= FindResource16( hInst
, template, RT_DIALOG16
))) return 0;
1076 if (!(hmem
= LoadResource16( hInst
, hRsrc
))) return 0;
1077 if (!(data
= LockResource16( hmem
))) hwnd
= 0;
1078 else hwnd
= DIALOG_CreateIndirect( hInst
, data
, FALSE
, owner
,
1079 dlgProc
, param
, WIN_PROC_16
, TRUE
);
1081 ret
=(INT16
)DIALOG_DoDialogBox( hwnd
, owner
);
1082 if (data
) GlobalUnlock16( hmem
);
1083 FreeResource16( hmem
);
1088 /***********************************************************************
1089 * DialogBoxParamA (USER32.139)
1091 INT WINAPI
DialogBoxParamA( HINSTANCE hInst
, LPCSTR name
,
1092 HWND owner
, DLGPROC dlgProc
, LPARAM param
)
1095 HANDLE hrsrc
= FindResourceA( hInst
, name
, RT_DIALOGA
);
1096 if (!hrsrc
) return 0;
1097 hwnd
= DIALOG_CreateIndirect( hInst
, (LPVOID
)LoadResource(hInst
, hrsrc
),
1099 (DLGPROC16
) dlgProc
, param
, WIN_PROC_32A
, TRUE
);
1100 if (hwnd
) return DIALOG_DoDialogBox( hwnd
, owner
);
1105 /***********************************************************************
1106 * DialogBoxParamW (USER32.140)
1108 INT WINAPI
DialogBoxParamW( HINSTANCE hInst
, LPCWSTR name
,
1109 HWND owner
, DLGPROC dlgProc
, LPARAM param
)
1112 HANDLE hrsrc
= FindResourceW( hInst
, name
, RT_DIALOGW
);
1113 if (!hrsrc
) return 0;
1114 hwnd
= DIALOG_CreateIndirect( hInst
, (LPVOID
)LoadResource(hInst
, hrsrc
),
1116 (DLGPROC16
)dlgProc
, param
, WIN_PROC_32W
, TRUE
);
1117 if (hwnd
) return DIALOG_DoDialogBox( hwnd
, owner
);
1122 /***********************************************************************
1123 * DialogBoxIndirect16 (USER.218)
1125 INT16 WINAPI
DialogBoxIndirect16( HINSTANCE16 hInst
, HANDLE16 dlgTemplate
,
1126 HWND16 owner
, DLGPROC16 dlgProc
)
1128 return DialogBoxIndirectParam16( hInst
, dlgTemplate
, owner
, dlgProc
, 0 );
1132 /***********************************************************************
1133 * DialogBoxIndirectParam16 (USER.240)
1135 INT16 WINAPI
DialogBoxIndirectParam16( HINSTANCE16 hInst
, HANDLE16 dlgTemplate
,
1136 HWND16 owner
, DLGPROC16 dlgProc
,
1142 if (!(ptr
= GlobalLock16( dlgTemplate
))) return -1;
1143 hwnd
= DIALOG_CreateIndirect( hInst
, ptr
, FALSE
, owner
,
1144 dlgProc
, param
, WIN_PROC_16
, TRUE
);
1145 GlobalUnlock16( dlgTemplate
);
1146 if (hwnd
) return DIALOG_DoDialogBox( hwnd
, owner
);
1151 /***********************************************************************
1152 * DialogBoxIndirectParamA (USER32.136)
1154 INT WINAPI
DialogBoxIndirectParamA(HINSTANCE hInstance
, LPCVOID
template,
1155 HWND owner
, DLGPROC dlgProc
,
1158 HWND hwnd
= DIALOG_CreateIndirect( hInstance
, template, TRUE
, owner
,
1159 (DLGPROC16
) dlgProc
, param
, WIN_PROC_32A
, TRUE
);
1160 if (hwnd
) return DIALOG_DoDialogBox( hwnd
, owner
);
1165 /***********************************************************************
1166 * DialogBoxIndirectParamW (USER32.138)
1168 INT WINAPI
DialogBoxIndirectParamW(HINSTANCE hInstance
, LPCVOID
template,
1169 HWND owner
, DLGPROC dlgProc
,
1172 HWND hwnd
= DIALOG_CreateIndirect( hInstance
, template, TRUE
, owner
,
1173 (DLGPROC16
)dlgProc
, param
, WIN_PROC_32W
, TRUE
);
1174 if (hwnd
) return DIALOG_DoDialogBox( hwnd
, owner
);
1178 /***********************************************************************
1179 * DialogBoxIndirectParamAorW (USER32.138)
1181 INT WINAPI
DialogBoxIndirectParamAorW(HINSTANCE hInstance
, LPCVOID
template,
1182 HWND owner
, DLGPROC dlgProc
,
1183 LPARAM param
, DWORD x
)
1186 FIXME("0x%08x %p 0x%08x %p 0x%08lx 0x%08lx\n",
1187 hInstance
, template, owner
, dlgProc
, param
, x
);
1188 hwnd
= DIALOG_CreateIndirect( hInstance
, template, TRUE
, owner
,
1189 (DLGPROC16
)dlgProc
, param
, WIN_PROC_32W
, TRUE
);
1190 if (hwnd
) return DIALOG_DoDialogBox( hwnd
, owner
);
1194 /***********************************************************************
1195 * EndDialog16 (USER.88)
1197 BOOL16 WINAPI
EndDialog16( HWND16 hwnd
, INT16 retval
)
1199 return EndDialog( hwnd
, retval
);
1203 /***********************************************************************
1204 * EndDialog (USER32.173)
1206 BOOL WINAPI
EndDialog( HWND hwnd
, INT retval
)
1208 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1209 BOOL wasEnabled
= TRUE
;
1210 DIALOGINFO
* dlgInfo
;
1212 TRACE("%04x %d\n", hwnd
, retval
);
1216 ERR("got invalid window handle (%04x); buggy app !?\n", hwnd
);
1220 if ((dlgInfo
= (DIALOGINFO
*)wndPtr
->wExtra
))
1222 dlgInfo
->idResult
= retval
;
1223 dlgInfo
->flags
|= DF_END
;
1224 wasEnabled
= (dlgInfo
->flags
& DF_OWNERENABLED
);
1228 DIALOG_EnableOwner( wndPtr
->owner
->hwndSelf
, wasEnabled
);
1230 /* Windows sets the focus to the dialog itself in EndDialog */
1232 if (IsChild(hwnd
, GetFocus()))
1233 SetFocus(wndPtr
->hwndSelf
);
1235 /* Don't have to send a ShowWindow(SW_HIDE), just do
1236 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1238 SetWindowPos(hwnd
, (HWND
)0, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
1239 | SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_HIDEWINDOW
);
1241 WIN_ReleaseWndPtr(wndPtr
);
1247 /***********************************************************************
1248 * DIALOG_IsAccelerator
1250 static BOOL
DIALOG_IsAccelerator( HWND hwnd
, HWND hwndDlg
, WPARAM vKey
)
1252 HWND hwndControl
= hwnd
;
1255 BOOL RetVal
= FALSE
;
1260 wndPtr
= WIN_FindWndPtr( hwndControl
);
1261 if ( (wndPtr
!= NULL
) &&
1262 ((wndPtr
->dwStyle
& (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
) )
1264 dlgCode
= SendMessageA( hwndControl
, WM_GETDLGCODE
, 0, 0 );
1265 if ( (dlgCode
& (DLGC_BUTTON
| DLGC_STATIC
)) &&
1266 (wndPtr
->text
!=NULL
))
1268 /* find the accelerator key */
1269 LPWSTR p
= wndPtr
->text
- 2;
1272 p
= strchrW( p
+ 2, '&' );
1274 while (p
!= NULL
&& p
[1] == '&');
1276 /* and check if it's the one we're looking for */
1277 /* FIXME: convert vKey to unicode */
1278 if (p
!= NULL
&& toupperW( p
[1] ) == (WCHAR
)toupper( vKey
) )
1280 if ((dlgCode
& DLGC_STATIC
) ||
1281 (wndPtr
->dwStyle
& 0x0f) == BS_GROUPBOX
)
1283 /* set focus to the control */
1284 SendMessageA( hwndDlg
, WM_NEXTDLGCTL
,
1286 /* and bump it on to next */
1287 SendMessageA( hwndDlg
, WM_NEXTDLGCTL
, 0, 0);
1289 else if (dlgCode
& DLGC_BUTTON
)
1291 /* send BM_CLICK message to the control */
1292 SendMessageA( hwndControl
, BM_CLICK
, 0, 0 );
1296 WIN_ReleaseWndPtr(wndPtr
);
1300 hwndNext
= GetWindow( hwndControl
, GW_CHILD
);
1306 WIN_ReleaseWndPtr(wndPtr
);
1309 hwndNext
= GetWindow( hwndControl
, GW_HWNDNEXT
);
1311 while (!hwndNext
&& hwndControl
)
1313 hwndControl
= GetParent( hwndControl
);
1314 if (hwndControl
== hwndDlg
)
1316 if(hwnd
==hwndDlg
){ /* prevent endless loop */
1320 hwndNext
= GetWindow( hwndDlg
, GW_CHILD
);
1324 hwndNext
= GetWindow( hwndControl
, GW_HWNDNEXT
);
1327 hwndControl
= hwndNext
;
1329 while (hwndControl
&& (hwndControl
!= hwnd
));
1334 /***********************************************************************
1335 * DIALOG_FindMsgDestination
1337 * The messages that IsDialogMessage sends may not go to the dialog
1338 * calling IsDialogMessage if that dialog is a child, and it has the
1339 * DS_CONTROL style set.
1340 * We propagate up until we hit one that does not have DS_CONTROL, or
1341 * whose parent is not a dialog.
1343 * This is undocumented behaviour.
1345 static HWND
DIALOG_FindMsgDestination( HWND hwndDlg
)
1347 while (GetWindowLongA(hwndDlg
, GWL_STYLE
) & DS_CONTROL
)
1350 HWND hParent
= GetParent(hwndDlg
);
1351 if (!hParent
) break;
1353 pParent
= WIN_FindWndPtr(hParent
);
1354 if (!pParent
) break;
1356 if (!(pParent
->flags
& WIN_ISDIALOG
))
1358 WIN_ReleaseWndPtr(pParent
);
1361 WIN_ReleaseWndPtr(pParent
);
1369 /***********************************************************************
1370 * DIALOG_IsDialogMessage
1372 static BOOL
DIALOG_IsDialogMessage( HWND hwnd
, HWND hwndDlg
,
1373 UINT message
, WPARAM wParam
,
1374 LPARAM lParam
, BOOL
*translate
,
1375 BOOL
*dispatch
, INT dlgCode
)
1377 *translate
= *dispatch
= FALSE
;
1379 if (message
== WM_PAINT
)
1381 /* Apparently, we have to handle this one as well */
1386 /* Only the key messages get special processing */
1387 if ((message
!= WM_KEYDOWN
) &&
1388 (message
!= WM_SYSCHAR
) &&
1389 (message
!= WM_CHAR
))
1392 if (dlgCode
& DLGC_WANTMESSAGE
)
1394 *translate
= *dispatch
= TRUE
;
1398 hwndDlg
= DIALOG_FindMsgDestination(hwndDlg
);
1406 if (!(dlgCode
& DLGC_WANTTAB
))
1408 SendMessageA( hwndDlg
, WM_NEXTDLGCTL
,
1409 (GetKeyState(VK_SHIFT
) & 0x8000), 0 );
1418 if (!(dlgCode
& DLGC_WANTARROWS
))
1420 BOOL fPrevious
= (wParam
== VK_LEFT
|| wParam
== VK_UP
);
1422 GetNextDlgGroupItem (hwndDlg
, GetFocus(), fPrevious
);
1423 SendMessageA( hwndDlg
, WM_NEXTDLGCTL
, hwndNext
, 1 );
1429 SendMessageA( hwndDlg
, WM_COMMAND
, IDCANCEL
,
1430 (LPARAM
)GetDlgItem( hwndDlg
, IDCANCEL
) );
1435 DWORD dw
= SendMessage16( hwndDlg
, DM_GETDEFID
, 0, 0 );
1436 if (HIWORD(dw
) == DC_HASDEFID
)
1438 SendMessageA( hwndDlg
, WM_COMMAND
,
1439 MAKEWPARAM( LOWORD(dw
), BN_CLICKED
),
1440 (LPARAM
)GetDlgItem(hwndDlg
, LOWORD(dw
)));
1444 SendMessageA( hwndDlg
, WM_COMMAND
, IDOK
,
1445 (LPARAM
)GetDlgItem( hwndDlg
, IDOK
) );
1452 break; /* case WM_KEYDOWN */
1455 if (dlgCode
& DLGC_WANTCHARS
) break;
1459 if (DIALOG_IsAccelerator( hwnd
, hwndDlg
, wParam
))
1461 /* don't translate or dispatch */
1467 /* If we get here, the message has not been treated specially */
1468 /* and can be sent to its destination window. */
1474 /***********************************************************************
1475 * IsDialogMessage16 (USER.90)
1477 BOOL16 WINAPI
WIN16_IsDialogMessage16( HWND16 hwndDlg
, SEGPTR msg16
)
1479 LPMSG16 msg
= PTR_SEG_TO_LIN(msg16
);
1480 BOOL ret
, translate
, dispatch
;
1483 if ((hwndDlg
!= msg
->hwnd
) && !IsChild16( hwndDlg
, msg
->hwnd
))
1486 if ((msg
->message
== WM_KEYDOWN
) ||
1487 (msg
->message
== WM_SYSCHAR
) ||
1488 (msg
->message
== WM_CHAR
))
1490 dlgCode
= SendMessage16( msg
->hwnd
, WM_GETDLGCODE
, 0, (LPARAM
)msg16
);
1492 ret
= DIALOG_IsDialogMessage( msg
->hwnd
, hwndDlg
, msg
->message
,
1493 msg
->wParam
, msg
->lParam
,
1494 &translate
, &dispatch
, dlgCode
);
1495 if (translate
) TranslateMessage16( msg
);
1496 if (dispatch
) DispatchMessage16( msg
);
1501 BOOL16 WINAPI
IsDialogMessage16( HWND16 hwndDlg
, LPMSG16 msg
)
1503 LPMSG16 msg16
= SEGPTR_NEW(MSG16
);
1507 ret
= WIN16_IsDialogMessage16( hwndDlg
, SEGPTR_GET(msg16
) );
1512 /***********************************************************************
1513 * IsDialogMessageA (USER32.342)
1515 BOOL WINAPI
IsDialogMessageA( HWND hwndDlg
, LPMSG msg
)
1517 BOOL ret
, translate
, dispatch
;
1520 if ((hwndDlg
!= msg
->hwnd
) && !IsChild( hwndDlg
, msg
->hwnd
))
1523 if ((msg
->message
== WM_KEYDOWN
) ||
1524 (msg
->message
== WM_SYSCHAR
) ||
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
);
1538 /***********************************************************************
1539 * IsDialogMessageW (USER32.343)
1541 BOOL WINAPI
IsDialogMessageW( HWND hwndDlg
, LPMSG msg
)
1543 BOOL ret
, translate
, dispatch
;
1546 if ((hwndDlg
!= msg
->hwnd
) && !IsChild( hwndDlg
, msg
->hwnd
))
1549 if ((msg
->message
== WM_KEYDOWN
) ||
1550 (msg
->message
== WM_SYSCHAR
) ||
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
);
1564 /***********************************************************************
1565 * GetDlgCtrlID16 (USER.277)
1567 INT16 WINAPI
GetDlgCtrlID16( HWND16 hwnd
)
1569 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
1572 if (!wndPtr
) return 0;
1574 retvalue
= wndPtr
->wIDmenu
;
1575 WIN_ReleaseWndPtr(wndPtr
);
1580 /***********************************************************************
1581 * GetDlgCtrlID (USER32.234)
1583 INT WINAPI
GetDlgCtrlID( HWND hwnd
)
1586 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
1587 if (!wndPtr
) return 0;
1588 retvalue
= wndPtr
->wIDmenu
;
1589 WIN_ReleaseWndPtr(wndPtr
);
1594 /***********************************************************************
1595 * GetDlgItem16 (USER.91)
1597 HWND16 WINAPI
GetDlgItem16( HWND16 hwndDlg
, INT16 id
)
1601 if (!(pWnd
= WIN_FindWndPtr( hwndDlg
))) return 0;
1602 for (WIN_UpdateWndPtr(&pWnd
,pWnd
->child
); pWnd
; WIN_UpdateWndPtr(&pWnd
,pWnd
->next
))
1603 if (pWnd
->wIDmenu
== (UINT16
)id
)
1605 HWND16 retvalue
= pWnd
->hwndSelf
;
1606 WIN_ReleaseWndPtr(pWnd
);
1613 /***********************************************************************
1614 * GetDlgItem (USER32.235)
1616 HWND WINAPI
GetDlgItem( HWND hwndDlg
, INT id
)
1620 if (!(pWnd
= WIN_FindWndPtr( hwndDlg
))) return 0;
1621 for (WIN_UpdateWndPtr(&pWnd
,pWnd
->child
); pWnd
;WIN_UpdateWndPtr(&pWnd
,pWnd
->next
))
1622 if (pWnd
->wIDmenu
== (UINT16
)id
)
1624 HWND retvalue
= pWnd
->hwndSelf
;
1625 WIN_ReleaseWndPtr(pWnd
);
1632 /*******************************************************************
1633 * SendDlgItemMessage16 (USER.101)
1635 LRESULT WINAPI
SendDlgItemMessage16( HWND16 hwnd
, INT16 id
, UINT16 msg
,
1636 WPARAM16 wParam
, LPARAM lParam
)
1638 HWND16 hwndCtrl
= GetDlgItem16( hwnd
, id
);
1639 if (hwndCtrl
) return SendMessage16( hwndCtrl
, msg
, wParam
, lParam
);
1644 /*******************************************************************
1645 * SendDlgItemMessageA (USER32.452)
1647 LRESULT WINAPI
SendDlgItemMessageA( HWND hwnd
, INT id
, UINT msg
,
1648 WPARAM wParam
, LPARAM lParam
)
1650 HWND hwndCtrl
= GetDlgItem( hwnd
, id
);
1651 if (hwndCtrl
) return SendMessageA( hwndCtrl
, msg
, wParam
, lParam
);
1656 /*******************************************************************
1657 * SendDlgItemMessageW (USER32.453)
1659 LRESULT WINAPI
SendDlgItemMessageW( HWND hwnd
, INT id
, UINT msg
,
1660 WPARAM wParam
, LPARAM lParam
)
1662 HWND hwndCtrl
= GetDlgItem( hwnd
, id
);
1663 if (hwndCtrl
) return SendMessageW( hwndCtrl
, msg
, wParam
, lParam
);
1668 /*******************************************************************
1669 * SetDlgItemText16 (USER.92)
1671 void WINAPI
SetDlgItemText16( HWND16 hwnd
, INT16 id
, SEGPTR lpString
)
1673 SendDlgItemMessage16( hwnd
, id
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1677 /*******************************************************************
1678 * SetDlgItemTextA (USER32.478)
1680 BOOL WINAPI
SetDlgItemTextA( HWND hwnd
, INT id
, LPCSTR lpString
)
1682 return SendDlgItemMessageA( hwnd
, id
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1686 /*******************************************************************
1687 * SetDlgItemTextW (USER32.479)
1689 BOOL WINAPI
SetDlgItemTextW( HWND hwnd
, INT id
, LPCWSTR lpString
)
1691 return SendDlgItemMessageW( hwnd
, id
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
1695 /***********************************************************************
1696 * GetDlgItemText16 (USER.93)
1698 INT16 WINAPI
GetDlgItemText16( HWND16 hwnd
, INT16 id
, SEGPTR str
, UINT16 len
)
1700 return (INT16
)SendDlgItemMessage16( hwnd
, id
, WM_GETTEXT
,
1705 /***********************************************************************
1706 * GetDlgItemTextA (USER32.237)
1708 INT WINAPI
GetDlgItemTextA( HWND hwnd
, INT id
, LPSTR str
, UINT len
)
1710 return (INT
)SendDlgItemMessageA( hwnd
, id
, WM_GETTEXT
,
1715 /***********************************************************************
1716 * GetDlgItemTextW (USER32.238)
1718 INT WINAPI
GetDlgItemTextW( HWND hwnd
, INT id
, LPWSTR str
, UINT len
)
1720 return (INT
)SendDlgItemMessageW( hwnd
, id
, WM_GETTEXT
,
1725 /*******************************************************************
1726 * SetDlgItemInt16 (USER.94)
1728 void WINAPI
SetDlgItemInt16( HWND16 hwnd
, INT16 id
, UINT16 value
, BOOL16 fSigned
)
1730 SetDlgItemInt( hwnd
, (UINT
)(UINT16
)id
, value
, fSigned
);
1734 /*******************************************************************
1735 * SetDlgItemInt (USER32.477)
1737 BOOL WINAPI
SetDlgItemInt( HWND hwnd
, INT id
, UINT value
,
1742 if (fSigned
) sprintf( str
, "%d", (INT
)value
);
1743 else sprintf( str
, "%u", value
);
1744 SendDlgItemMessageA( hwnd
, id
, WM_SETTEXT
, 0, (LPARAM
)str
);
1749 /***********************************************************************
1750 * GetDlgItemInt16 (USER.95)
1752 UINT16 WINAPI
GetDlgItemInt16( HWND16 hwnd
, INT16 id
, BOOL16
*translated
,
1758 if (translated
) *translated
= FALSE
;
1759 result
= GetDlgItemInt( hwnd
, (UINT
)(UINT16
)id
, &ok
, fSigned
);
1763 if (((INT
)result
< -32767) || ((INT
)result
> 32767)) return 0;
1767 if (result
> 65535) return 0;
1769 if (translated
) *translated
= TRUE
;
1770 return (UINT16
)result
;
1774 /***********************************************************************
1775 * GetDlgItemInt (USER32.236)
1777 UINT WINAPI
GetDlgItemInt( HWND hwnd
, INT id
, BOOL
*translated
,
1784 if (translated
) *translated
= FALSE
;
1785 if (!SendDlgItemMessageA(hwnd
, id
, WM_GETTEXT
, sizeof(str
), (LPARAM
)str
))
1789 result
= strtol( str
, &endptr
, 10 );
1790 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
1792 if (((result
== LONG_MIN
) || (result
== LONG_MAX
)) && (errno
==ERANGE
))
1797 result
= strtoul( str
, &endptr
, 10 );
1798 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
1800 if ((result
== ULONG_MAX
) && (errno
== ERANGE
)) return 0;
1802 if (translated
) *translated
= TRUE
;
1803 return (UINT
)result
;
1807 /***********************************************************************
1808 * CheckDlgButton16 (USER.97)
1810 BOOL16 WINAPI
CheckDlgButton16( HWND16 hwnd
, INT16 id
, UINT16 check
)
1812 SendDlgItemMessageA( hwnd
, id
, BM_SETCHECK
, check
, 0 );
1817 /***********************************************************************
1818 * CheckDlgButton (USER32.45)
1820 BOOL WINAPI
CheckDlgButton( HWND hwnd
, INT id
, UINT check
)
1822 SendDlgItemMessageA( hwnd
, id
, BM_SETCHECK
, check
, 0 );
1827 /***********************************************************************
1828 * IsDlgButtonChecked16 (USER.98)
1830 UINT16 WINAPI
IsDlgButtonChecked16( HWND16 hwnd
, UINT16 id
)
1832 return (UINT16
)SendDlgItemMessageA( hwnd
, id
, BM_GETCHECK
, 0, 0 );
1836 /***********************************************************************
1837 * IsDlgButtonChecked (USER32.344)
1839 UINT WINAPI
IsDlgButtonChecked( HWND hwnd
, UINT id
)
1841 return (UINT
)SendDlgItemMessageA( hwnd
, id
, BM_GETCHECK
, 0, 0 );
1845 /***********************************************************************
1846 * CheckRadioButton16 (USER.96)
1848 BOOL16 WINAPI
CheckRadioButton16( HWND16 hwndDlg
, UINT16 firstID
,
1849 UINT16 lastID
, UINT16 checkID
)
1851 return CheckRadioButton( hwndDlg
, firstID
, lastID
, checkID
);
1855 /***********************************************************************
1858 * Callback function used to check/uncheck radio buttons that fall
1859 * within a specific range of IDs.
1861 static BOOL CALLBACK
CheckRB(HWND hwndChild
, LPARAM lParam
)
1863 LONG lChildID
= GetWindowLongA(hwndChild
, GWL_ID
);
1864 RADIOGROUP
*lpRadioGroup
= (RADIOGROUP
*) lParam
;
1866 if ((lChildID
>= lpRadioGroup
->firstID
) &&
1867 (lChildID
<= lpRadioGroup
->lastID
))
1869 if (lChildID
== lpRadioGroup
->checkID
)
1871 SendMessageA(hwndChild
, BM_SETCHECK
, BST_CHECKED
, 0);
1875 SendMessageA(hwndChild
, BM_SETCHECK
, BST_UNCHECKED
, 0);
1883 /***********************************************************************
1884 * CheckRadioButton (USER32.48)
1886 BOOL WINAPI
CheckRadioButton( HWND hwndDlg
, UINT firstID
,
1887 UINT lastID
, UINT checkID
)
1889 RADIOGROUP radioGroup
;
1891 /* perform bounds checking for a radio button group */
1892 radioGroup
.firstID
= min(min(firstID
, lastID
), checkID
);
1893 radioGroup
.lastID
= max(max(firstID
, lastID
), checkID
);
1894 radioGroup
.checkID
= checkID
;
1896 return EnumChildWindows(hwndDlg
, (WNDENUMPROC
)CheckRB
,
1897 (LPARAM
)&radioGroup
);
1901 /***********************************************************************
1902 * GetDialogBaseUnits (USER.243) (USER32.233)
1904 DWORD WINAPI
GetDialogBaseUnits(void)
1906 return MAKELONG( xBaseUnit
, yBaseUnit
);
1910 /***********************************************************************
1911 * MapDialogRect16 (USER.103)
1913 void WINAPI
MapDialogRect16( HWND16 hwnd
, LPRECT16 rect
)
1915 DIALOGINFO
* dlgInfo
;
1916 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1917 if (!wndPtr
) return;
1918 dlgInfo
= (DIALOGINFO
*)wndPtr
->wExtra
;
1919 rect
->left
= MulDiv(rect
->left
, dlgInfo
->xBaseUnit
, 4);
1920 rect
->right
= MulDiv(rect
->right
, dlgInfo
->xBaseUnit
, 4);
1921 rect
->top
= MulDiv(rect
->top
, dlgInfo
->yBaseUnit
, 8);
1922 rect
->bottom
= MulDiv(rect
->bottom
, dlgInfo
->yBaseUnit
, 8);
1923 WIN_ReleaseWndPtr(wndPtr
);
1927 /***********************************************************************
1928 * MapDialogRect (USER32.382)
1930 BOOL WINAPI
MapDialogRect( HWND hwnd
, LPRECT rect
)
1932 DIALOGINFO
* dlgInfo
;
1933 WND
* wndPtr
= WIN_FindWndPtr( hwnd
);
1934 if (!wndPtr
) return FALSE
;
1935 dlgInfo
= (DIALOGINFO
*)wndPtr
->wExtra
;
1936 rect
->left
= MulDiv(rect
->left
, dlgInfo
->xBaseUnit
, 4);
1937 rect
->right
= MulDiv(rect
->right
, dlgInfo
->xBaseUnit
, 4);
1938 rect
->top
= MulDiv(rect
->top
, dlgInfo
->yBaseUnit
, 8);
1939 rect
->bottom
= MulDiv(rect
->bottom
, dlgInfo
->yBaseUnit
, 8);
1940 WIN_ReleaseWndPtr(wndPtr
);
1945 /***********************************************************************
1946 * GetNextDlgGroupItem16 (USER.227)
1948 HWND16 WINAPI
GetNextDlgGroupItem16( HWND16 hwndDlg
, HWND16 hwndCtrl
,
1951 return (HWND16
)GetNextDlgGroupItem( hwndDlg
, hwndCtrl
, fPrevious
);
1955 /***********************************************************************
1956 * GetNextDlgGroupItem (USER32.275)
1958 HWND WINAPI
GetNextDlgGroupItem( HWND hwndDlg
, HWND hwndCtrl
,
1969 /* if the hwndCtrl is the child of the control in the hwndDlg,
1970 * then the hwndDlg has to be the parent of the hwndCtrl */
1971 if(GetParent(hwndCtrl
) != hwndDlg
&& GetParent(GetParent(hwndCtrl
)) == hwndDlg
)
1972 hwndDlg
= GetParent(hwndCtrl
);
1975 if (!(pWndDlg
= WIN_FindWndPtr( hwndDlg
))) return 0;
1978 if (!(pWndCtrl
= WIN_FindWndPtr( hwndCtrl
)))
1983 /* Make sure hwndCtrl is a top-level child */
1984 while ((pWndCtrl
->dwStyle
& WS_CHILD
) && (pWndCtrl
->parent
!= pWndDlg
))
1985 WIN_UpdateWndPtr(&pWndCtrl
,pWndCtrl
->parent
);
1986 if (pWndCtrl
->parent
!= pWndDlg
)
1994 /* No ctrl specified -> start from the beginning */
1995 if (!(pWndCtrl
= WIN_LockWndPtr(pWndDlg
->child
)))
2001 while (pWndCtrl
->next
) WIN_UpdateWndPtr(&pWndCtrl
,pWndCtrl
->next
);
2004 pWndLast
= WIN_LockWndPtr(pWndCtrl
);
2005 pWnd
= WIN_LockWndPtr(pWndCtrl
->next
);
2009 if (!pWnd
|| (pWnd
->dwStyle
& WS_GROUP
))
2011 /* Wrap-around to the beginning of the group */
2014 WIN_UpdateWndPtr( &pWnd
, pWndDlg
->child
);
2015 for ( pWndTemp
= WIN_LockWndPtr( pWnd
);
2017 WIN_UpdateWndPtr( &pWndTemp
, pWndTemp
->next
) )
2019 if (pWndTemp
->dwStyle
& WS_GROUP
) WIN_UpdateWndPtr( &pWnd
, pWndTemp
);
2020 if (pWndTemp
== pWndCtrl
) break;
2022 WIN_ReleaseWndPtr( pWndTemp
);
2024 if (pWnd
== pWndCtrl
) break;
2025 if ((pWnd
->dwStyle
& WS_VISIBLE
) && !(pWnd
->dwStyle
& WS_DISABLED
))
2027 WIN_UpdateWndPtr(&pWndLast
,pWnd
);
2028 if (!fPrevious
) break;
2030 WIN_UpdateWndPtr(&pWnd
,pWnd
->next
);
2032 retvalue
= pWndLast
->hwndSelf
;
2034 WIN_ReleaseWndPtr(pWndLast
);
2035 WIN_ReleaseWndPtr(pWnd
);
2037 WIN_ReleaseWndPtr(pWndCtrl
);
2038 WIN_ReleaseWndPtr(pWndDlg
);
2044 /***********************************************************************
2045 * GetNextDlgTabItem16 (USER.228)
2047 HWND16 WINAPI
GetNextDlgTabItem16( HWND16 hwndDlg
, HWND16 hwndCtrl
,
2050 return (HWND16
)GetNextDlgTabItem( hwndDlg
, hwndCtrl
, fPrevious
);
2053 /***********************************************************************
2054 * DIALOG_GetNextTabItem
2056 * Helper for GetNextDlgTabItem
2058 static HWND
DIALOG_GetNextTabItem( HWND hwndMain
, HWND hwndDlg
, HWND hwndCtrl
, BOOL fPrevious
)
2062 UINT wndSearch
= fPrevious
? GW_HWNDPREV
: GW_HWNDNEXT
;
2064 HWND hChildFirst
= 0;
2068 hChildFirst
= GetWindow(hwndDlg
,GW_CHILD
);
2069 if(fPrevious
) hChildFirst
= GetWindow(hChildFirst
,GW_HWNDLAST
);
2073 HWND hParent
= GetParent(hwndCtrl
);
2074 BOOL bValid
= FALSE
;
2077 if(hParent
== hwndMain
)
2082 hParent
= GetParent(hParent
);
2086 hChildFirst
= GetWindow(hwndCtrl
,wndSearch
);
2089 if(GetParent(hwndCtrl
) != hwndMain
)
2090 hChildFirst
= GetWindow(GetParent(hwndCtrl
),wndSearch
);
2094 hChildFirst
= GetWindow(hwndCtrl
,GW_HWNDLAST
);
2096 hChildFirst
= GetWindow(hwndCtrl
,GW_HWNDFIRST
);
2106 dsStyle
= GetWindowLongA(hChildFirst
,GWL_STYLE
);
2107 exStyle
= GetWindowLongA(hChildFirst
,GWL_EXSTYLE
);
2108 if( (dsStyle
& DS_CONTROL
|| exStyle
& WS_EX_CONTROLPARENT
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
2113 else if( (dsStyle
& WS_TABSTOP
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
2115 hChildFirst
= GetWindow(hChildFirst
,wndSearch
);
2120 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hChildFirst
,(HWND
)NULL
,fPrevious
);
2122 retWnd
= hChildFirst
;
2125 hChildFirst
= GetWindow(hChildFirst
,wndSearch
);
2127 if(!retWnd
&& hwndCtrl
)
2129 HWND hParent
= GetParent(hwndCtrl
);
2132 if(hParent
== hwndMain
) break;
2133 retWnd
= DIALOG_GetNextTabItem(hwndMain
,GetParent(hParent
),hParent
,fPrevious
);
2135 hParent
= GetParent(hParent
);
2138 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hwndMain
,(HWND
)NULL
,fPrevious
);
2143 /***********************************************************************
2144 * GetNextDlgTabItem (USER32.276)
2146 HWND WINAPI
GetNextDlgTabItem( HWND hwndDlg
, HWND hwndCtrl
,
2149 return DIALOG_GetNextTabItem(hwndDlg
,hwndDlg
,hwndCtrl
,fPrevious
);
2152 /**********************************************************************
2153 * DIALOG_DlgDirSelect
2155 * Helper function for DlgDirSelect*
2157 static BOOL
DIALOG_DlgDirSelect( HWND hwnd
, LPSTR str
, INT len
,
2158 INT id
, BOOL win32
, BOOL unicode
,
2164 HWND listbox
= GetDlgItem( hwnd
, id
);
2166 TRACE("%04x '%s' %d\n", hwnd
, str
, id
);
2167 if (!listbox
) return FALSE
;
2170 item
= SendMessageA(listbox
, combo
? CB_GETCURSEL
2171 : LB_GETCURSEL
, 0, 0 );
2172 if (item
== LB_ERR
) return FALSE
;
2173 size
= SendMessageA(listbox
, combo
? CB_GETLBTEXTLEN
2174 : LB_GETTEXTLEN
, 0, 0 );
2175 if (size
== LB_ERR
) return FALSE
;
2179 item
= SendMessageA(listbox
, combo
? CB_GETCURSEL16
2180 : LB_GETCURSEL16
, 0, 0 );
2181 if (item
== LB_ERR
) return FALSE
;
2182 size
= SendMessageA(listbox
, combo
? CB_GETLBTEXTLEN16
2183 : LB_GETTEXTLEN16
, 0, 0 );
2184 if (size
== LB_ERR
) return FALSE
;
2187 if (!(buffer
= SEGPTR_ALLOC( size
+1 ))) return FALSE
;
2190 SendMessageA( listbox
, combo
? CB_GETLBTEXT
: LB_GETTEXT
,
2191 item
, (LPARAM
)buffer
);
2193 SendMessage16( listbox
, combo
? CB_GETLBTEXT16
: LB_GETTEXT16
,
2194 item
, (LPARAM
)SEGPTR_GET(buffer
) );
2196 if ((ret
= (buffer
[0] == '['))) /* drive or directory */
2198 if (buffer
[1] == '-') /* drive */
2206 buffer
[strlen(buffer
)-1] = '\\';
2212 if (unicode
) lstrcpynAtoW( (LPWSTR
)str
, ptr
, len
);
2213 else lstrcpynA( str
, ptr
, len
);
2214 SEGPTR_FREE( buffer
);
2215 TRACE("Returning %d '%s'\n", ret
, str
);
2220 /**********************************************************************
2223 * Helper function for DlgDirList*
2225 static INT
DIALOG_DlgDirList( HWND hDlg
, LPSTR spec
, INT idLBox
,
2226 INT idStatic
, UINT attrib
, BOOL combo
)
2230 LPSTR orig_spec
= spec
;
2232 #define SENDMSG(msg,wparam,lparam) \
2233 ((attrib & DDL_POSTMSGS) ? PostMessageA( hwnd, msg, wparam, lparam ) \
2234 : SendMessageA( hwnd, msg, wparam, lparam ))
2236 TRACE("%04x '%s' %d %d %04x\n",
2237 hDlg
, spec
? spec
: "NULL", idLBox
, idStatic
, attrib
);
2239 if (spec
&& spec
[0] && (spec
[1] == ':'))
2241 drive
= toupper( spec
[0] ) - 'A';
2243 if (!DRIVE_SetCurrentDrive( drive
)) return FALSE
;
2245 else drive
= DRIVE_GetCurrentDrive();
2247 /* If the path exists and is a directory, chdir to it */
2248 if (!spec
|| !spec
[0] || DRIVE_Chdir( drive
, spec
)) spec
= "*.*";
2253 if ((p2
= strrchr( p
, '\\' ))) p
= p2
;
2254 if ((p2
= strrchr( p
, '/' ))) p
= p2
;
2259 if (!DRIVE_Chdir( drive
, spec
))
2261 *p
= sep
; /* Restore the original spec */
2268 TRACE("path=%c:\\%s mask=%s\n",
2269 'A' + drive
, DRIVE_GetDosCwd(drive
), spec
);
2271 if (idLBox
&& ((hwnd
= GetDlgItem( hDlg
, idLBox
)) != 0))
2273 SENDMSG( combo
? CB_RESETCONTENT
: LB_RESETCONTENT
, 0, 0 );
2274 if (attrib
& DDL_DIRECTORY
)
2276 if (!(attrib
& DDL_EXCLUSIVE
))
2278 if (SENDMSG( combo
? CB_DIR
: LB_DIR
,
2279 attrib
& ~(DDL_DIRECTORY
| DDL_DRIVES
),
2280 (LPARAM
)spec
) == LB_ERR
)
2283 if (SENDMSG( combo
? CB_DIR
: LB_DIR
,
2284 (attrib
& (DDL_DIRECTORY
| DDL_DRIVES
)) | DDL_EXCLUSIVE
,
2285 (LPARAM
)"*.*" ) == LB_ERR
)
2290 if (SENDMSG( combo
? CB_DIR
: LB_DIR
, attrib
,
2291 (LPARAM
)spec
) == LB_ERR
)
2296 if (idStatic
&& ((hwnd
= GetDlgItem( hDlg
, idStatic
)) != 0))
2299 int drive
= DRIVE_GetCurrentDrive();
2300 strcpy( temp
, "A:\\" );
2302 lstrcpynA( temp
+ 3, DRIVE_GetDosCwd(drive
), sizeof(temp
)-3 );
2304 /* Can't use PostMessage() here, because the string is on the stack */
2305 SetDlgItemTextA( hDlg
, idStatic
, temp
);
2308 if (orig_spec
&& (spec
!= orig_spec
))
2310 /* Update the original file spec */
2312 while ((*orig_spec
++ = *p
++));
2320 /**********************************************************************
2321 * DIALOG_DlgDirListW
2323 * Helper function for DlgDirList*W
2325 static INT
DIALOG_DlgDirListW( HWND hDlg
, LPWSTR spec
, INT idLBox
,
2326 INT idStatic
, UINT attrib
, BOOL combo
)
2330 LPSTR specA
= HEAP_strdupWtoA( GetProcessHeap(), 0, spec
);
2331 INT ret
= DIALOG_DlgDirList( hDlg
, specA
, idLBox
, idStatic
,
2333 lstrcpyAtoW( spec
, specA
);
2334 HeapFree( GetProcessHeap(), 0, specA
);
2337 return DIALOG_DlgDirList( hDlg
, NULL
, idLBox
, idStatic
, attrib
, combo
);
2341 /**********************************************************************
2342 * DlgDirSelect (USER.99)
2344 BOOL16 WINAPI
DlgDirSelect16( HWND16 hwnd
, LPSTR str
, INT16 id
)
2346 return DlgDirSelectEx16( hwnd
, str
, 128, id
);
2350 /**********************************************************************
2351 * DlgDirSelectComboBox (USER.194)
2353 BOOL16 WINAPI
DlgDirSelectComboBox16( HWND16 hwnd
, LPSTR str
, INT16 id
)
2355 return DlgDirSelectComboBoxEx16( hwnd
, str
, 128, id
);
2359 /**********************************************************************
2360 * DlgDirSelectEx16 (USER.422)
2362 BOOL16 WINAPI
DlgDirSelectEx16( HWND16 hwnd
, LPSTR str
, INT16 len
, INT16 id
)
2364 return DIALOG_DlgDirSelect( hwnd
, str
, len
, id
, FALSE
, FALSE
, FALSE
);
2368 /**********************************************************************
2369 * DlgDirSelectExA (USER32.149)
2371 BOOL WINAPI
DlgDirSelectExA( HWND hwnd
, LPSTR str
, INT len
, INT id
)
2373 return DIALOG_DlgDirSelect( hwnd
, str
, len
, id
, TRUE
, FALSE
, FALSE
);
2377 /**********************************************************************
2378 * DlgDirSelectExW (USER32.150)
2380 BOOL WINAPI
DlgDirSelectExW( HWND hwnd
, LPWSTR str
, INT len
, INT id
)
2382 return DIALOG_DlgDirSelect( hwnd
, (LPSTR
)str
, len
, id
, TRUE
, TRUE
, FALSE
);
2386 /**********************************************************************
2387 * DlgDirSelectComboBoxEx16 (USER.423)
2389 BOOL16 WINAPI
DlgDirSelectComboBoxEx16( HWND16 hwnd
, LPSTR str
, INT16 len
,
2392 return DIALOG_DlgDirSelect( hwnd
, str
, len
, id
, FALSE
, FALSE
, TRUE
);
2396 /**********************************************************************
2397 * DlgDirSelectComboBoxExA (USER32.147)
2399 BOOL WINAPI
DlgDirSelectComboBoxExA( HWND hwnd
, LPSTR str
, INT len
,
2402 return DIALOG_DlgDirSelect( hwnd
, str
, len
, id
, TRUE
, FALSE
, TRUE
);
2406 /**********************************************************************
2407 * DlgDirSelectComboBoxExW (USER32.148)
2409 BOOL WINAPI
DlgDirSelectComboBoxExW( HWND hwnd
, LPWSTR str
, INT len
,
2412 return DIALOG_DlgDirSelect( hwnd
, (LPSTR
)str
, len
, id
, TRUE
, TRUE
, TRUE
);
2416 /**********************************************************************
2417 * DlgDirList16 (USER.100)
2419 INT16 WINAPI
DlgDirList16( HWND16 hDlg
, LPSTR spec
, INT16 idLBox
,
2420 INT16 idStatic
, UINT16 attrib
)
2422 return DIALOG_DlgDirList( hDlg
, spec
, idLBox
, idStatic
, attrib
, FALSE
);
2426 /**********************************************************************
2427 * DlgDirListA (USER32.143)
2429 INT WINAPI
DlgDirListA( HWND hDlg
, LPSTR spec
, INT idLBox
,
2430 INT idStatic
, UINT attrib
)
2432 return DIALOG_DlgDirList( hDlg
, spec
, idLBox
, idStatic
, attrib
, FALSE
);
2436 /**********************************************************************
2437 * DlgDirListW (USER32.146)
2439 INT WINAPI
DlgDirListW( HWND hDlg
, LPWSTR spec
, INT idLBox
,
2440 INT idStatic
, UINT attrib
)
2442 return DIALOG_DlgDirListW( hDlg
, spec
, idLBox
, idStatic
, attrib
, FALSE
);
2446 /**********************************************************************
2447 * DlgDirListComboBox16 (USER.195)
2449 INT16 WINAPI
DlgDirListComboBox16( HWND16 hDlg
, LPSTR spec
, INT16 idCBox
,
2450 INT16 idStatic
, UINT16 attrib
)
2452 return DIALOG_DlgDirList( hDlg
, spec
, idCBox
, idStatic
, attrib
, TRUE
);
2456 /**********************************************************************
2457 * DlgDirListComboBoxA (USER32.144)
2459 INT WINAPI
DlgDirListComboBoxA( HWND hDlg
, LPSTR spec
, INT idCBox
,
2460 INT idStatic
, UINT attrib
)
2462 return DIALOG_DlgDirList( hDlg
, spec
, idCBox
, idStatic
, attrib
, TRUE
);
2466 /**********************************************************************
2467 * DlgDirListComboBoxW (USER32.145)
2469 INT WINAPI
DlgDirListComboBoxW( HWND hDlg
, LPWSTR spec
, INT idCBox
,
2470 INT idStatic
, UINT attrib
)
2472 return DIALOG_DlgDirListW( hDlg
, spec
, idCBox
, idStatic
, attrib
, TRUE
);