3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * PROJECT: ReactOS user32.dll
21 * FILE: lib/user32/windows/dialog.c
23 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
24 * Thomas Weidenmueller (w3seek@users.sourceforge.net)
25 * Steven Edwards (Steven_Ed4153@yahoo.com)
27 * 07-26-2003 Code ported from wine
28 * 09-05-2001 CSH Created
31 /* INCLUDES ******************************************************************/
35 #include <wine/debug.h>
36 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
38 /* MACROS/DEFINITIONS ********************************************************/
41 #define DF_OWNERENABLED 0x0002
42 #define DWLP_ROS_DIALOGINFO (DWLP_USER+sizeof(ULONG_PTR))
43 #define GETDLGINFO(hwnd) DIALOG_get_info(hwnd, FALSE)
44 #define SETDLGINFO(hwnd, info) SetWindowLongPtrW((hwnd), DWLP_ROS_DIALOGINFO, (LONG_PTR)(info))
45 #define GET_WORD(ptr) (*(WORD *)(ptr))
46 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
47 void WINAPI
WinPosActivateOtherWindow(HWND hwnd
);
49 /* INTERNAL STRUCTS **********************************************************/
51 /* Dialog info structure */
54 HWND hwndFocus
; /* Current control with focus */
55 HFONT hUserFont
; /* Dialog font */
56 HMENU hMenu
; /* Dialog menu */
57 UINT xBaseUnit
; /* Dialog units (depends on the font) */
59 INT idResult
; /* EndDialog() result / default pushbutton ID */
60 UINT flags
; /* EndDialog() called for this dialog */
63 /* Dialog control information */
101 /* CheckRadioButton structure */
110 /*********************************************************************
111 * dialog class descriptor
113 const struct builtin_class_descr DIALOG_builtin_class
=
115 WC_DIALOG
, /* name */
116 CS_SAVEBITS
| CS_DBLCLKS
, /* style */
117 (WNDPROC
) DefDlgProcA
, /* procA */
118 (WNDPROC
) DefDlgProcW
, /* procW */
119 DLGWINDOWEXTRA
, /* extra */
120 (LPCWSTR
) IDC_ARROW
, /* cursor */
125 /* INTERNAL FUNCTIONS ********************************************************/
127 /***********************************************************************
130 * Get the DIALOGINFO structure of a window, allocating it if needed
131 * and 'create' is TRUE.
135 DIALOGINFO
* DIALOG_get_info( HWND hWnd
, BOOL create
)
138 DIALOGINFO
* dlgInfo
= (DIALOGINFO
*)GetWindowLongPtrW( hWnd
, DWLP_ROS_DIALOGINFO
);
140 if(!dlgInfo
&& create
)
142 pWindow
= ValidateHwnd( hWnd
);
145 SetLastError( ERROR_INVALID_WINDOW_HANDLE
);
149 if (pWindow
&& pWindow
->cbwndExtra
>= DLGWINDOWEXTRA
&& hWnd
!= GetDesktopWindow())
151 if (!(dlgInfo
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*dlgInfo
) )))
154 SETDLGINFO( hWnd
, dlgInfo
);
156 NtUserCallHwndParam( hWnd
, (DWORD_PTR
)dlgInfo
, HWNDPARAM_ROUTINE_SETDIALOGPOINTER
);
166 /***********************************************************************
169 * Helper function for modal dialogs to enable again the
170 * owner of the dialog box.
172 void DIALOG_EnableOwner( HWND hOwner
)
174 /* Owner must be a top-level window */
176 hOwner
= GetAncestor( hOwner
, GA_ROOT
);
178 EnableWindow( hOwner
, TRUE
);
182 /***********************************************************************
183 * DIALOG_DisableOwner
185 * Helper function for modal dialogs to disable the
186 * owner of the dialog box. Returns TRUE if owner was enabled.
188 BOOL
DIALOG_DisableOwner( HWND hOwner
)
190 /* Owner must be a top-level window */
192 hOwner
= GetAncestor( hOwner
, GA_ROOT
);
193 if (!hOwner
) return FALSE
;
194 if (IsWindowEnabled( hOwner
))
196 EnableWindow( hOwner
, FALSE
);
203 /***********************************************************************
204 * DIALOG_GetControl32
206 * Return the class and text of the control pointed to by ptr,
207 * fill the header structure and return a pointer to the next control.
209 static const WORD
*DIALOG_GetControl32( const WORD
*p
, DLG_CONTROL_INFO
*info
,
214 info
->helpId
= GET_DWORD(p
); p
+= 2;
215 info
->exStyle
= GET_DWORD(p
); p
+= 2;
216 info
->style
= GET_DWORD(p
); p
+= 2;
221 info
->style
= GET_DWORD(p
); p
+= 2;
222 info
->exStyle
= GET_DWORD(p
); p
+= 2;
224 info
->x
= GET_WORD(p
); p
++;
225 info
->y
= GET_WORD(p
); p
++;
226 info
->cx
= GET_WORD(p
); p
++;
227 info
->cy
= GET_WORD(p
); p
++;
231 /* id is a DWORD for DIALOGEX */
232 info
->id
= GET_DWORD(p
);
237 info
->id
= GET_WORD(p
);
241 if (GET_WORD(p
) == 0xffff)
243 static const WCHAR class_names
[6][10] =
245 { 'B','u','t','t','o','n', }, /* 0x80 */
246 { 'E','d','i','t', }, /* 0x81 */
247 { 'S','t','a','t','i','c', }, /* 0x82 */
248 { 'L','i','s','t','B','o','x', }, /* 0x83 */
249 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
250 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
252 WORD id
= GET_WORD(p
+1);
253 /* Windows treats dialog control class ids 0-5 same way as 0x80-0x85 */
254 if ((id
>= 0x80) && (id
<= 0x85)) id
-= 0x80;
256 info
->className
= class_names
[id
];
259 info
->className
= NULL
;
260 /* FIXME: load other classes here? */
266 info
->className
= (LPCWSTR
)p
;
267 p
+= strlenW( info
->className
) + 1;
270 if (GET_WORD(p
) == 0xffff) /* Is it an integer id? */
272 //// ReactOS Rev 6478
273 info
->windowName
= HeapAlloc( GetProcessHeap(), 0, sizeof(L
"#65535") );
274 if (info
->windowName
!= NULL
)
276 swprintf((LPWSTR
)info
->windowName
, L
"#%d", GET_WORD(p
+ 1));
277 info
->windowNameFree
= TRUE
;
281 info
->windowNameFree
= FALSE
;
287 info
->windowName
= (LPCWSTR
)p
;
288 info
->windowNameFree
= FALSE
;
289 p
+= strlenW( info
->windowName
) + 1;
295 p
+= GET_WORD(p
) / sizeof(WORD
);
297 else info
->data
= NULL
;
300 /* Next control is on dword boundary */
301 return (const WORD
*)(((UINT_PTR
)p
+ 3) & ~3);
305 /***********************************************************************
306 * DIALOG_CreateControls32
308 * Create the control windows for a dialog.
310 static BOOL
DIALOG_CreateControls32( HWND hwnd
, LPCSTR
template, const DLG_TEMPLATE
*dlgTemplate
,
311 HINSTANCE hInst
, BOOL unicode
)
313 DIALOGINFO
* dlgInfo
;
314 DLG_CONTROL_INFO info
;
315 HWND hwndCtrl
, hwndDefButton
= 0;
316 INT items
= dlgTemplate
->nbItems
;
318 if (!(dlgInfo
= GETDLGINFO(hwnd
))) return FALSE
;
322 template = (LPCSTR
)DIALOG_GetControl32( (const WORD
*)template, &info
,
323 dlgTemplate
->dialogEx
);
325 if (info
.style
& WS_BORDER
)
327 info
.style
&= ~WS_BORDER
;
328 info
.exStyle
|= WS_EX_CLIENTEDGE
;
332 hwndCtrl
= CreateWindowExW( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
333 info
.className
, info
.windowName
,
334 info
.style
| WS_CHILD
,
335 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
336 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
337 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
338 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
339 hwnd
, (HMENU
)(ULONG_PTR
)info
.id
,
340 hInst
, (LPVOID
)info
.data
);
344 LPSTR
class = (LPSTR
)info
.className
;
345 LPSTR caption
= (LPSTR
)info
.windowName
;
349 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, info
.className
, -1, NULL
, 0, NULL
, NULL
);
350 class = HeapAlloc( GetProcessHeap(), 0, len
);
352 WideCharToMultiByte( CP_ACP
, 0, info
.className
, -1, class, len
, NULL
, NULL
);
356 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, info
.windowName
, -1, NULL
, 0, NULL
, NULL
);
357 caption
= HeapAlloc( GetProcessHeap(), 0, len
);
359 WideCharToMultiByte( CP_ACP
, 0, info
.windowName
, -1, caption
, len
, NULL
, NULL
);
362 if (class != NULL
&& caption
!= NULL
)
364 hwndCtrl
= CreateWindowExA( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
365 class, caption
, info
.style
| WS_CHILD
,
366 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
367 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
368 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
369 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
370 hwnd
, (HMENU
)(ULONG_PTR
)info
.id
,
371 hInst
, (LPVOID
)info
.data
);
375 if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
376 if (HIWORD(caption
)) HeapFree( GetProcessHeap(), 0, caption
);
379 if (info
.windowNameFree
)
381 HeapFree( GetProcessHeap(), 0, (LPVOID
)info
.windowName
);
386 if (dlgTemplate
->style
& DS_NOFAILCREATE
) continue;
390 /* Send initialisation messages to the control */
391 if (dlgInfo
->hUserFont
) SendMessageW( hwndCtrl
, WM_SETFONT
,
392 (WPARAM
)dlgInfo
->hUserFont
, 0 );
393 if (SendMessageW(hwndCtrl
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
)
395 /* If there's already a default push-button, set it back */
396 /* to normal and use this one instead. */
398 SendMessageW( hwndDefButton
, BM_SETSTYLE
, BS_PUSHBUTTON
, FALSE
);
399 hwndDefButton
= hwndCtrl
;
400 dlgInfo
->idResult
= GetWindowLongPtrA( hwndCtrl
, GWLP_ID
);
406 /***********************************************************************
407 * DIALOG_FindMsgDestination
409 * The messages that IsDialogMessage sends may not go to the dialog
410 * calling IsDialogMessage if that dialog is a child, and it has the
411 * DS_CONTROL style set.
412 * We propagate up until we hit one that does not have DS_CONTROL, or
413 * whose parent is not a dialog.
415 * This is undocumented behaviour.
417 static HWND
DIALOG_FindMsgDestination( HWND hwndDlg
)
419 while (GetWindowLongA(hwndDlg
, GWL_STYLE
) & DS_CONTROL
)
422 HWND hParent
= GetParent(hwndDlg
);
425 if (!IsWindow(hParent
)) break;
427 pWnd
= ValidateHwnd(hParent
);
428 // FIXME: Use pWnd->fnid == FNID_DESKTOP
429 if (!pWnd
|| hParent
== GetDesktopWindow()) break;
431 if (!(pWnd
->state
& WNDS_DIALOGWINDOW
))
442 /***********************************************************************
443 * DIALOG_IsAccelerator
445 static BOOL
DIALOG_IsAccelerator( HWND hwnd
, HWND hwndDlg
, WPARAM wParam
)
447 HWND hwndControl
= hwnd
;
454 DWORD style
= GetWindowLongPtrW( hwndControl
, GWL_STYLE
);
455 if ((style
& (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
)
457 dlgCode
= SendMessageA( hwndControl
, WM_GETDLGCODE
, 0, 0 );
458 if ( (dlgCode
& (DLGC_BUTTON
| DLGC_STATIC
)) &&
459 GetWindowTextW( hwndControl
, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
461 /* find the accelerator key */
462 LPWSTR p
= buffer
- 2;
466 p
= wcschr( p
+ 2, '&' );
468 while (p
!= NULL
&& p
[1] == '&');
470 /* and check if it's the one we're looking for */
471 if (p
!= NULL
&& toupperW( p
[1] ) == toupperW( wParam
) )
473 if ((dlgCode
& DLGC_STATIC
) || (style
& 0x0f) == BS_GROUPBOX
)
475 /* set focus to the control */
476 SendMessageW( hwndDlg
, WM_NEXTDLGCTL
, (WPARAM
)hwndControl
, 1);
477 /* and bump it on to next */
478 SendMessageW( hwndDlg
, WM_NEXTDLGCTL
, 0, 0);
480 else if (dlgCode
& DLGC_BUTTON
)
482 /* send BM_CLICK message to the control */
483 SendMessageW( hwndControl
, BM_CLICK
, 0, 0 );
488 hwndNext
= GetWindow( hwndControl
, GW_CHILD
);
492 if (!hwndNext
) hwndNext
= GetWindow( hwndControl
, GW_HWNDNEXT
);
494 while (!hwndNext
&& hwndControl
)
496 hwndControl
= GetParent( hwndControl
);
497 if (hwndControl
== hwndDlg
)
499 if(hwnd
==hwndDlg
) /* prevent endless loop */
504 hwndNext
= GetWindow( hwndDlg
, GW_CHILD
);
507 hwndNext
= GetWindow( hwndControl
, GW_HWNDNEXT
);
509 hwndControl
= hwndNext
;
511 while (hwndControl
&& (hwndControl
!= hwnd
));
516 /***********************************************************************
519 INT
DIALOG_DoDialogBox( HWND hwnd
, HWND owner
)
521 DIALOGINFO
* dlgInfo
;
524 HWND ownerMsg
= GetAncestor( owner
, GA_ROOT
);
527 if (!(dlgInfo
= GETDLGINFO(hwnd
))) return -1;
530 if (!(dlgInfo
->flags
& DF_END
)) /* was EndDialog called in WM_INITDIALOG ? */
534 if (!PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
))
538 /* ShowWindow the first time the queue goes empty */
539 ShowWindow( hwnd
, SW_SHOWNORMAL
);
542 if (!(GetWindowLongPtrW( hwnd
, GWL_STYLE
) & DS_NOIDLEMSG
))
544 /* No message present -> send ENTERIDLE and wait */
545 SendMessageW( ownerMsg
, WM_ENTERIDLE
, MSGF_DIALOGBOX
, (LPARAM
)hwnd
);
547 if (!GetMessageW( &msg
, 0, 0, 0 )) break;
550 if (!IsWindow( hwnd
)) return 0;
551 if (!(dlgInfo
->flags
& DF_END
) && !IsDialogMessageW( hwnd
, &msg
))
553 TranslateMessage( &msg
);
554 DispatchMessageW( &msg
);
556 if (dlgInfo
->flags
& DF_END
) break;
558 if (bFirstEmpty
&& msg
.message
== WM_TIMER
)
560 ShowWindow( hwnd
, SW_SHOWNORMAL
);
565 if (dlgInfo
->flags
& DF_OWNERENABLED
) DIALOG_EnableOwner( owner
);
566 retval
= dlgInfo
->idResult
;
567 DestroyWindow( hwnd
);
571 /***********************************************************************
572 * DIALOG_ParseTemplate32
574 * Fill a DLG_TEMPLATE structure from the dialog template, and return
575 * a pointer to the first control.
577 static LPCSTR
DIALOG_ParseTemplate32( LPCSTR
template, DLG_TEMPLATE
* result
)
579 const WORD
*p
= (const WORD
*)template;
583 dlgver
= GET_WORD(p
); p
++;
584 signature
= GET_WORD(p
); p
++;
586 if (dlgver
== 1 && signature
== 0xffff) /* DIALOGEX resource */
588 result
->dialogEx
= TRUE
;
589 result
->helpId
= GET_DWORD(p
); p
+= 2;
590 result
->exStyle
= GET_DWORD(p
); p
+= 2;
591 result
->style
= GET_DWORD(p
); p
+= 2;
595 result
->style
= GET_DWORD(p
- 2);
596 result
->dialogEx
= FALSE
;
598 result
->exStyle
= GET_DWORD(p
); p
+= 2;
600 result
->nbItems
= GET_WORD(p
); p
++;
601 result
->x
= GET_WORD(p
); p
++;
602 result
->y
= GET_WORD(p
); p
++;
603 result
->cx
= GET_WORD(p
); p
++;
604 result
->cy
= GET_WORD(p
); p
++;
606 /* Get the menu name */
611 result
->menuName
= NULL
;
615 result
->menuName
= (LPCWSTR
)(UINT_PTR
)GET_WORD( p
+ 1 );
619 result
->menuName
= (LPCWSTR
)p
;
620 p
+= strlenW( result
->menuName
) + 1;
624 /* Get the class name */
629 result
->className
= WC_DIALOG
;
633 result
->className
= (LPCWSTR
)(UINT_PTR
)GET_WORD( p
+ 1 );
637 result
->className
= (LPCWSTR
)p
;
638 p
+= strlenW( result
->className
) + 1;
642 /* Get the window caption */
644 result
->caption
= (LPCWSTR
)p
;
645 p
+= strlenW( result
->caption
) + 1;
647 /* Get the font name */
649 result
->pointSize
= 0;
650 result
->faceName
= NULL
;
651 result
->weight
= FW_DONTCARE
;
652 result
->italic
= FALSE
;
654 if (result
->style
& DS_SETFONT
)
656 result
->pointSize
= GET_WORD(p
);
659 /* If pointSize is 0x7fff, it means that we need to use the font
660 * in NONCLIENTMETRICSW.lfMessageFont, and NOT read the weight,
661 * italic, and facename from the dialog template.
663 if (result
->pointSize
== 0x7fff)
665 /* We could call SystemParametersInfo here, but then we'd have
666 * to convert from pixel size to point size (which can be
669 TRACE(" FONT: Using message box font\n");
673 if (result
->dialogEx
)
675 result
->weight
= GET_WORD(p
); p
++;
676 result
->italic
= LOBYTE(GET_WORD(p
)); p
++;
678 result
->faceName
= (LPCWSTR
)p
;
679 p
+= strlenW( result
->faceName
) + 1;
683 /* First control is on dword boundary */
684 return (LPCSTR
)((((UINT_PTR
)p
) + 3) & ~3);
687 /***********************************************************************
690 * Set the focus to a control of the dialog, selecting the text if
691 * the control is an edit dialog.
693 static void DEFDLG_SetFocus( HWND hwndDlg
, HWND hwndCtrl
)
695 if (SendMessageW( hwndCtrl
, WM_GETDLGCODE
, 0, 0 ) & DLGC_HASSETSEL
)
696 SendMessageW( hwndCtrl
, EM_SETSEL
, 0, -1 );
697 SetFocus( hwndCtrl
);
701 /***********************************************************************
704 static void DEFDLG_SaveFocus( HWND hwnd
)
707 HWND hwndFocus
= GetFocus();
709 if (!hwndFocus
|| !IsChild( hwnd
, hwndFocus
)) return;
710 if (!(infoPtr
= GETDLGINFO(hwnd
))) return;
711 infoPtr
->hwndFocus
= hwndFocus
;
712 /* Remove default button */
716 /***********************************************************************
717 * DEFDLG_RestoreFocus
719 static void DEFDLG_RestoreFocus( HWND hwnd
)
723 if (IsIconic( hwnd
)) return;
724 if (!(infoPtr
= GETDLGINFO(hwnd
))) return;
725 /* Don't set the focus back to controls if EndDialog is already called.*/
726 if (infoPtr
->flags
& DF_END
) return;
727 if (!IsWindow(infoPtr
->hwndFocus
) || infoPtr
->hwndFocus
== hwnd
) {
728 /* If no saved focus control exists, set focus to the first visible,
729 non-disabled, WS_TABSTOP control in the dialog */
730 infoPtr
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
731 if (!IsWindow( infoPtr
->hwndFocus
)) return;
733 DEFDLG_SetFocus( hwnd
, infoPtr
->hwndFocus
);
735 /* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
736 sometimes losing focus when receiving WM_SETFOCUS messages. */
739 /***********************************************************************
740 * DIALOG_CreateIndirect
741 * Creates a dialog box window
743 * modal = TRUE if we are called from a modal dialog box.
744 * (it's more compatible to do it here, as under Windows the owner
745 * is never disabled if the dialog fails because of an invalid template)
747 static HWND
DIALOG_CreateIndirect( HINSTANCE hInst
, LPCVOID dlgTemplate
,
748 HWND owner
, DLGPROC dlgProc
, LPARAM param
,
749 BOOL unicode
, BOOL modal
)
755 DLG_TEMPLATE
template;
756 DIALOGINFO
* dlgInfo
= NULL
;
757 DWORD units
= GetDialogBaseUnits();
758 BOOL ownerEnabled
= TRUE
;
762 UINT xBaseUnit
= LOWORD(units
);
763 UINT yBaseUnit
= HIWORD(units
);
765 /* Parse dialog template */
767 if (!dlgTemplate
) return 0;
768 dlgTemplate
= DIALOG_ParseTemplate32( dlgTemplate
, &template );
772 if (template.menuName
) hMenu
= LoadMenuW( hInst
, template.menuName
);
774 /* Create custom font if needed */
776 if (template.style
& DS_SETFONT
)
780 if (template.pointSize
== 0x7fff)
782 /* We get the message font from the non-client metrics */
783 NONCLIENTMETRICSW ncMetrics
;
785 ncMetrics
.cbSize
= sizeof(NONCLIENTMETRICSW
);
786 if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS
,
787 sizeof(NONCLIENTMETRICSW
), &ncMetrics
, 0))
789 hUserFont
= CreateFontIndirectW( &ncMetrics
.lfMessageFont
);
794 /* We convert the size to pixels and then make it -ve. This works
795 * for both +ve and -ve template.pointSize */
796 int pixels
= MulDiv(template.pointSize
, GetDeviceCaps(dc
, LOGPIXELSY
), 72);
797 hUserFont
= CreateFontW( -pixels
, 0, 0, 0, template.weight
,
798 template.italic
, FALSE
, FALSE
, DEFAULT_CHARSET
, 0, 0,
799 PROOF_QUALITY
, FF_DONTCARE
,
806 HFONT hOldFont
= SelectObject( dc
, hUserFont
);
807 charSize
.cx
= GdiGetCharDimensions( dc
, NULL
, &charSize
.cy
);
810 xBaseUnit
= charSize
.cx
;
811 yBaseUnit
= charSize
.cy
;
813 SelectObject( dc
, hOldFont
);
816 TRACE("units = %d,%d\n", xBaseUnit
, yBaseUnit
);
819 /* Create dialog main window */
821 rect
.left
= rect
.top
= 0;
822 rect
.right
= MulDiv(template.cx
, xBaseUnit
, 4);
823 rect
.bottom
= MulDiv(template.cy
, yBaseUnit
, 8);
824 if (template.style
& WS_CHILD
)
825 template.style
&= ~(WS_CAPTION
|WS_SYSMENU
);
826 if (template.style
& DS_MODALFRAME
)
827 template.exStyle
|= WS_EX_DLGMODALFRAME
;
828 if (template.style
& DS_CONTROL
)
829 template.exStyle
|= WS_EX_CONTROLPARENT
;
830 AdjustWindowRectEx( &rect
, template.style
, (hMenu
!= 0), template.exStyle
);
833 size
.cx
= rect
.right
- rect
.left
;
834 size
.cy
= rect
.bottom
- rect
.top
;
836 if (template.x
== CW_USEDEFAULT16
)
838 pos
.x
= pos
.y
= CW_USEDEFAULT
;
842 HMONITOR monitor
= 0;
843 MONITORINFO mon_info
;
845 mon_info
.cbSize
= sizeof(mon_info
);
846 if (template.style
& DS_CENTER
)
848 monitor
= MonitorFromWindow( owner
? owner
: GetActiveWindow(), MONITOR_DEFAULTTOPRIMARY
);
849 GetMonitorInfoW( monitor
, &mon_info
);
850 pos
.x
= (mon_info
.rcWork
.left
+ mon_info
.rcWork
.right
- size
.cx
) / 2;
851 pos
.y
= (mon_info
.rcWork
.top
+ mon_info
.rcWork
.bottom
- size
.cy
) / 2;
853 else if (template.style
& DS_CENTERMOUSE
)
855 GetCursorPos( &pos
);
856 monitor
= MonitorFromPoint( pos
, MONITOR_DEFAULTTOPRIMARY
);
857 GetMonitorInfoW( monitor
, &mon_info
);
861 pos
.x
+= MulDiv(template.x
, xBaseUnit
, 4);
862 pos
.y
+= MulDiv(template.y
, yBaseUnit
, 8);
863 if (!(template.style
& (WS_CHILD
|DS_ABSALIGN
))) ClientToScreen( owner
, &pos
);
865 if ( !(template.style
& WS_CHILD
) )
869 /* try to fit it into the desktop */
873 SetRect( &rect
, pos
.x
, pos
.y
, pos
.x
+ size
.cx
, pos
.y
+ size
.cy
);
874 monitor
= MonitorFromRect( &rect
, MONITOR_DEFAULTTOPRIMARY
);
875 GetMonitorInfoW( monitor
, &mon_info
);
877 if ((dX
= pos
.x
+ size
.cx
+ GetSystemMetrics(SM_CXDLGFRAME
) - mon_info
.rcWork
.right
) > 0)
879 if ((dY
= pos
.y
+ size
.cy
+ GetSystemMetrics(SM_CYDLGFRAME
) - mon_info
.rcWork
.bottom
) > 0)
881 if( pos
.x
< mon_info
.rcWork
.left
) pos
.x
= mon_info
.rcWork
.left
;
882 if( pos
.y
< mon_info
.rcWork
.top
) pos
.y
= mon_info
.rcWork
.top
;
888 ownerEnabled
= DIALOG_DisableOwner( owner
);
889 if (ownerEnabled
) flags
|= DF_OWNERENABLED
;
894 hwnd
= CreateWindowExW(template.exStyle
, template.className
, template.caption
,
895 template.style
& ~WS_VISIBLE
, pos
.x
, pos
.y
, size
.cx
, size
.cy
,
896 owner
, hMenu
, hInst
, NULL
);
900 LPCSTR
class = (LPCSTR
)template.className
;
901 LPCSTR caption
= (LPCSTR
)template.caption
;
902 LPSTR class_tmp
= NULL
;
903 LPSTR caption_tmp
= NULL
;
907 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, template.className
, -1, NULL
, 0, NULL
, NULL
);
908 class_tmp
= HeapAlloc( GetProcessHeap(), 0, len
);
909 WideCharToMultiByte( CP_ACP
, 0, template.className
, -1, class_tmp
, len
, NULL
, NULL
);
914 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, template.caption
, -1, NULL
, 0, NULL
, NULL
);
915 caption_tmp
= HeapAlloc( GetProcessHeap(), 0, len
);
916 WideCharToMultiByte( CP_ACP
, 0, template.caption
, -1, caption_tmp
, len
, NULL
, NULL
);
917 caption
= caption_tmp
;
919 hwnd
= CreateWindowExA(template.exStyle
, class, caption
,
920 template.style
& ~WS_VISIBLE
, pos
.x
, pos
.y
, size
.cx
, size
.cy
,
921 owner
, hMenu
, hInst
, NULL
);
922 HeapFree( GetProcessHeap(), 0, class_tmp
);
923 HeapFree( GetProcessHeap(), 0, caption_tmp
);
928 if (hUserFont
) DeleteObject( hUserFont
);
929 if (hMenu
) DestroyMenu( hMenu
);
930 if (modal
&& (flags
& DF_OWNERENABLED
)) DIALOG_EnableOwner(owner
);
934 /* moved this from the top of the method to here as DIALOGINFO structure
935 will be valid only after WM_CREATE message has been handled in DefDlgProc
936 All the members of the structure get filled here using temp variables */
937 dlgInfo
= DIALOG_get_info( hwnd
, TRUE
);
940 if (hUserFont
) DeleteObject( hUserFont
);
941 if (hMenu
) DestroyMenu( hMenu
);
942 if (modal
&& (flags
& DF_OWNERENABLED
)) DIALOG_EnableOwner(owner
);
946 dlgInfo
->hwndFocus
= 0;
947 dlgInfo
->hUserFont
= hUserFont
;
948 dlgInfo
->hMenu
= hMenu
;
949 dlgInfo
->xBaseUnit
= xBaseUnit
;
950 dlgInfo
->yBaseUnit
= yBaseUnit
;
951 dlgInfo
->idResult
= IDOK
;
952 dlgInfo
->flags
= flags
;
954 if (template.helpId
) SetWindowContextHelpId( hwnd
, template.helpId
);
956 if (unicode
) SetWindowLongPtrW( hwnd
, DWLP_DLGPROC
, (ULONG_PTR
)dlgProc
);
957 else SetWindowLongPtrA( hwnd
, DWLP_DLGPROC
, (ULONG_PTR
)dlgProc
);
959 if (dlgProc
&& dlgInfo
->hUserFont
)
960 SendMessageW( hwnd
, WM_SETFONT
, (WPARAM
)dlgInfo
->hUserFont
, 0 );
962 /* Create controls */
964 if (DIALOG_CreateControls32( hwnd
, dlgTemplate
, &template, hInst
, unicode
))
966 /* Send initialisation messages and set focus */
970 HWND focus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
971 if (SendMessageW( hwnd
, WM_INITDIALOG
, (WPARAM
)focus
, param
) &&
972 ((~template.style
& DS_CONTROL
) || (template.style
& WS_VISIBLE
)))
974 /* By returning TRUE, app has requested a default focus assignment.
975 * WM_INITDIALOG may have changed the tab order, so find the first
976 * tabstop control again. */
977 dlgInfo
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
978 if( dlgInfo
->hwndFocus
)
979 SetFocus( dlgInfo
->hwndFocus
);
982 DEFDLG_SaveFocus( hwnd
);
985 //// ReactOS Rev 30613 & 30644
986 if (!(GetWindowLongPtrW( hwnd
, GWL_STYLE
) & WS_CHILD
))
987 SendMessageW( hwnd
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_INITIALIZE
, 0), 0);
989 if (template.style
& WS_VISIBLE
&& !(GetWindowLongPtrW( hwnd
, GWL_STYLE
) & WS_VISIBLE
))
991 ShowWindow( hwnd
, SW_SHOWNORMAL
); /* SW_SHOW doesn't always work */
995 if (modal
&& ownerEnabled
) DIALOG_EnableOwner(owner
);
996 if( IsWindow(hwnd
) ) DestroyWindow( hwnd
);
1001 /***********************************************************************
1002 * DEFDLG_FindDefButton
1004 * Find the current default push-button.
1006 static HWND
DEFDLG_FindDefButton( HWND hwndDlg
)
1008 HWND hwndChild
, hwndTmp
;
1010 hwndChild
= GetWindow( hwndDlg
, GW_CHILD
);
1013 if (SendMessageW( hwndChild
, WM_GETDLGCODE
, 0, 0 ) & DLGC_DEFPUSHBUTTON
)
1016 /* Recurse into WS_EX_CONTROLPARENT controls */
1017 if (GetWindowLongPtrW( hwndChild
, GWL_EXSTYLE
) & WS_EX_CONTROLPARENT
)
1019 LONG dsStyle
= GetWindowLongPtrW( hwndChild
, GWL_STYLE
);
1020 if ((dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
) &&
1021 (hwndTmp
= DEFDLG_FindDefButton(hwndChild
)) != NULL
)
1024 hwndChild
= GetWindow( hwndChild
, GW_HWNDNEXT
);
1030 /***********************************************************************
1033 * Set the default button id.
1035 static BOOL
DEFDLG_SetDefId( HWND hwndDlg
, DIALOGINFO
*dlgInfo
, WPARAM wParam
)
1037 DWORD dlgcode
=0; /* initialize just to avoid a warning */
1038 HWND hwndOld
, hwndNew
= GetDlgItem(hwndDlg
, wParam
);
1039 INT old_id
= dlgInfo
->idResult
;
1041 dlgInfo
->idResult
= wParam
;
1043 !((dlgcode
=SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 ))
1044 & (DLGC_UNDEFPUSHBUTTON
| DLGC_BUTTON
)))
1045 return FALSE
; /* Destination is not a push button */
1047 /* Make sure the old default control is a valid push button ID */
1048 hwndOld
= GetDlgItem( hwndDlg
, old_id
);
1049 if (!hwndOld
|| !(SendMessageW( hwndOld
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
1050 hwndOld
= DEFDLG_FindDefButton( hwndDlg
);
1051 if (hwndOld
&& hwndOld
!= hwndNew
)
1052 SendMessageW( hwndOld
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
1056 if(dlgcode
& DLGC_UNDEFPUSHBUTTON
)
1057 SendMessageW( hwndNew
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
1063 /***********************************************************************
1064 * DEFDLG_SetDefButton
1066 * Set the new default button to be hwndNew.
1068 static BOOL
DEFDLG_SetDefButton( HWND hwndDlg
, DIALOGINFO
*dlgInfo
, HWND hwndNew
)
1070 DWORD dlgcode
=0; /* initialize just to avoid a warning */
1071 HWND hwndOld
= GetDlgItem( hwndDlg
, dlgInfo
->idResult
);
1074 !((dlgcode
=SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 ))
1075 & (DLGC_UNDEFPUSHBUTTON
| DLGC_DEFPUSHBUTTON
)))
1078 * Need to draw only default push button rectangle.
1079 * Since the next control is not a push button, need to draw the push
1080 * button rectangle for the default control.
1083 dlgcode
= SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 );
1086 /* Make sure the old default control is a valid push button ID */
1087 if (!hwndOld
|| !(SendMessageW( hwndOld
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
1088 hwndOld
= DEFDLG_FindDefButton( hwndDlg
);
1089 if (hwndOld
&& hwndOld
!= hwndNew
)
1090 SendMessageW( hwndOld
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
1094 if(dlgcode
& DLGC_UNDEFPUSHBUTTON
)
1095 SendMessageW( hwndNew
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
1101 /***********************************************************************
1104 * Implementation of DefDlgProc(). Only handle messages that need special
1105 * handling for dialogs.
1107 static LRESULT
DEFDLG_Proc( HWND hwnd
, UINT msg
, WPARAM wParam
,
1108 LPARAM lParam
, DIALOGINFO
*dlgInfo
)
1114 HBRUSH brush
= (HBRUSH
)SendMessageW( hwnd
, WM_CTLCOLORDLG
, wParam
, (LPARAM
)hwnd
);
1115 if (!brush
) brush
= (HBRUSH
)DefWindowProcW( hwnd
, WM_CTLCOLORDLG
, wParam
, (LPARAM
)hwnd
);
1119 HDC hdc
= (HDC
)wParam
;
1120 GetClientRect( hwnd
, &rect
);
1121 DPtoLP( hdc
, (LPPOINT
)&rect
, 2 );
1122 FillRect( hdc
, &rect
, brush
);
1128 if ((dlgInfo
= (DIALOGINFO
*)SetWindowLongPtrW( hwnd
, DWLP_ROS_DIALOGINFO
, 0 )))
1130 if (dlgInfo
->hUserFont
) DeleteObject( dlgInfo
->hUserFont
);
1131 if (dlgInfo
->hMenu
) DestroyMenu( dlgInfo
->hMenu
);
1132 HeapFree( GetProcessHeap(), 0, dlgInfo
);
1133 NtUserCallHwndParam( hwnd
, 0, HWNDPARAM_ROUTINE_SETDIALOGPOINTER
);
1135 /* Window clean-up */
1136 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1139 if (!wParam
) DEFDLG_SaveFocus( hwnd
);
1140 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1143 if (wParam
) DEFDLG_RestoreFocus( hwnd
);
1144 else DEFDLG_SaveFocus( hwnd
);
1148 DEFDLG_RestoreFocus( hwnd
);
1152 if (dlgInfo
&& !(dlgInfo
->flags
& DF_END
))
1153 DEFDLG_SetDefId( hwnd
, dlgInfo
, wParam
);
1157 if (dlgInfo
&& !(dlgInfo
->flags
& DF_END
))
1160 if (dlgInfo
->idResult
)
1161 return MAKELONG( dlgInfo
->idResult
, DC_HASDEFID
);
1162 if ((hwndDefId
= DEFDLG_FindDefButton( hwnd
)))
1163 return MAKELONG( GetDlgCtrlID( hwndDefId
), DC_HASDEFID
);
1170 HWND hwndDest
= (HWND
)wParam
;
1172 hwndDest
= GetNextDlgTabItem(hwnd
, GetFocus(), wParam
);
1173 if (hwndDest
) DEFDLG_SetFocus( hwnd
, hwndDest
);
1174 DEFDLG_SetDefButton( hwnd
, dlgInfo
, hwndDest
);
1178 case WM_ENTERMENULOOP
:
1179 case WM_LBUTTONDOWN
:
1180 case WM_NCLBUTTONDOWN
:
1182 HWND hwndFocus
= GetFocus();
1185 /* always make combo box hide its listbox control */
1186 if (!SendMessageW( hwndFocus
, CB_SHOWDROPDOWN
, FALSE
, 0 ))
1187 SendMessageW( GetParent(hwndFocus
), CB_SHOWDROPDOWN
, FALSE
, 0 );
1190 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1193 return dlgInfo
? (LRESULT
)dlgInfo
->hUserFont
: 0;
1196 PostMessageA( hwnd
, WM_COMMAND
, MAKEWPARAM(IDCANCEL
, BN_CLICKED
),
1197 (LPARAM
)GetDlgItem( hwnd
, IDCANCEL
) );
1203 /***********************************************************************
1206 static LRESULT
DEFDLG_Epilog(HWND hwnd
, UINT msg
, BOOL fResult
)
1209 // TODO: where's wine's WM_CTLCOLOR from?
1210 if ((msg
>= WM_CTLCOLORMSGBOX
&& msg
<= WM_CTLCOLORSTATIC
) ||
1211 msg
== WM_CTLCOLOR
|| msg
== WM_COMPAREITEM
||
1212 msg
== WM_VKEYTOITEM
|| msg
== WM_CHARTOITEM
||
1213 msg
== WM_QUERYDRAGICON
|| msg
== WM_INITDIALOG
)
1216 return GetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
);
1219 /***********************************************************************
1220 * DIALOG_GetNextTabItem
1222 * Helper for GetNextDlgTabItem
1224 static HWND
DIALOG_GetNextTabItem( HWND hwndMain
, HWND hwndDlg
, HWND hwndCtrl
, BOOL fPrevious
)
1228 UINT wndSearch
= fPrevious
? GW_HWNDPREV
: GW_HWNDNEXT
;
1230 HWND hChildFirst
= 0;
1234 hChildFirst
= GetWindow(hwndDlg
,GW_CHILD
);
1235 if(fPrevious
) hChildFirst
= GetWindow(hChildFirst
,GW_HWNDLAST
);
1237 else if (IsChild( hwndMain
, hwndCtrl
))
1239 hChildFirst
= GetWindow(hwndCtrl
,wndSearch
);
1242 if(GetParent(hwndCtrl
) != hwndMain
)
1243 /* i.e. if we are not at the top level of the recursion */
1244 hChildFirst
= GetWindow(GetParent(hwndCtrl
),wndSearch
);
1246 hChildFirst
= GetWindow(hwndCtrl
, fPrevious
? GW_HWNDLAST
: GW_HWNDFIRST
);
1252 dsStyle
= GetWindowLongPtrA(hChildFirst
,GWL_STYLE
);
1253 exStyle
= GetWindowLongPtrA(hChildFirst
,GWL_EXSTYLE
);
1254 if( (exStyle
& WS_EX_CONTROLPARENT
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
1257 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hChildFirst
,NULL
,fPrevious
);
1258 if (retWnd
) return (retWnd
);
1260 else if( (dsStyle
& WS_TABSTOP
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
1262 return (hChildFirst
);
1264 hChildFirst
= GetWindow(hChildFirst
,wndSearch
);
1268 HWND hParent
= GetParent(hwndCtrl
);
1271 if(hParent
== hwndMain
) break;
1272 retWnd
= DIALOG_GetNextTabItem(hwndMain
,GetParent(hParent
),hParent
,fPrevious
);
1274 hParent
= GetParent(hParent
);
1277 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hwndMain
,NULL
,fPrevious
);
1279 return retWnd
? retWnd
: hwndCtrl
;
1282 /**********************************************************************
1283 * DIALOG_DlgDirListW
1285 * Helper function for DlgDirList*W
1287 static INT
DIALOG_DlgDirListW( HWND hDlg
, LPWSTR spec
, INT idLBox
,
1288 INT idStatic
, UINT attrib
, BOOL combo
)
1291 LPWSTR orig_spec
= spec
;
1292 WCHAR any
[] = {'*','.','*',0};
1294 #define SENDMSG(msg,wparam,lparam) \
1295 ((attrib & DDL_POSTMSGS) ? PostMessageW( hwnd, msg, wparam, lparam ) \
1296 : SendMessageW( hwnd, msg, wparam, lparam ))
1298 // TRACE("%p '%s' %d %d %04x\n",
1299 // hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
1301 /* If the path exists and is a directory, chdir to it */
1302 if (!spec
|| !spec
[0] || SetCurrentDirectoryW( spec
)) spec
= any
;
1307 if ((p2
= strchrW( p
, ':' ))) p
= p2
+ 1;
1308 if ((p2
= strrchrW( p
, '\\' ))) p
= p2
;
1309 if ((p2
= strrchrW( p
, '/' ))) p
= p2
;
1314 if (!SetCurrentDirectoryW( spec
))
1316 *p
= sep
; /* Restore the original spec */
1323 TRACE( "mask=%s\n", spec
);
1325 if (idLBox
&& ((hwnd
= GetDlgItem( hDlg
, idLBox
)) != 0))
1327 if (attrib
== DDL_DRIVES
) attrib
|= DDL_EXCLUSIVE
;
1329 SENDMSG( combo
? CB_RESETCONTENT
: LB_RESETCONTENT
, 0, 0 );
1330 if (attrib
& DDL_DIRECTORY
)
1332 if (!(attrib
& DDL_EXCLUSIVE
))
1334 SENDMSG( combo
? CB_DIR
: LB_DIR
,
1335 attrib
& ~(DDL_DIRECTORY
| DDL_DRIVES
),
1338 SENDMSG( combo
? CB_DIR
: LB_DIR
,
1339 (attrib
& (DDL_DIRECTORY
| DDL_DRIVES
)) | DDL_EXCLUSIVE
,
1344 SENDMSG( combo
? CB_DIR
: LB_DIR
, attrib
, (LPARAM
)spec
);
1348 /* Convert path specification to uppercase */
1349 if (spec
) CharUpperW(spec
);
1351 if (idStatic
&& ((hwnd
= GetDlgItem( hDlg
, idStatic
)) != 0))
1353 WCHAR temp
[MAX_PATH
];
1354 GetCurrentDirectoryW( sizeof(temp
)/sizeof(WCHAR
), temp
);
1356 /* Can't use PostMessage() here, because the string is on the stack */
1357 SetDlgItemTextW( hDlg
, idStatic
, temp
);
1360 if (orig_spec
&& (spec
!= orig_spec
))
1362 /* Update the original file spec */
1364 while ((*orig_spec
++ = *p
++));
1371 /**********************************************************************
1372 * DIALOG_DlgDirListA
1374 * Helper function for DlgDirList*A
1376 static INT
DIALOG_DlgDirListA( HWND hDlg
, LPSTR spec
, INT idLBox
,
1377 INT idStatic
, UINT attrib
, BOOL combo
)
1381 INT ret
, len
= MultiByteToWideChar( CP_ACP
, 0, spec
, -1, NULL
, 0 );
1382 LPWSTR specW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
1385 MultiByteToWideChar( CP_ACP
, 0, spec
, -1, specW
, len
);
1386 ret
= DIALOG_DlgDirListW( hDlg
, specW
, idLBox
, idStatic
, attrib
, combo
);
1387 WideCharToMultiByte( CP_ACP
, 0, specW
, -1, spec
, 0x7fffffff, NULL
, NULL
);
1388 HeapFree( GetProcessHeap(), 0, specW
);
1391 return DIALOG_DlgDirListW( hDlg
, NULL
, idLBox
, idStatic
, attrib
, combo
);
1394 /**********************************************************************
1395 * DIALOG_DlgDirSelect
1397 * Helper function for DlgDirSelect*
1399 static BOOL
DIALOG_DlgDirSelect( HWND hwnd
, LPWSTR str
, INT len
,
1400 INT id
, BOOL unicode
, BOOL combo
)
1402 WCHAR
*buffer
, *ptr
;
1405 HWND listbox
= GetDlgItem( hwnd
, id
);
1407 TRACE("%p %s %d\n", hwnd
, unicode
? debugstr_w(str
) : debugstr_a((LPSTR
)str
), id
);
1408 if (!listbox
) return FALSE
;
1410 item
= SendMessageW(listbox
, combo
? CB_GETCURSEL
: LB_GETCURSEL
, 0, 0 );
1411 if (item
== LB_ERR
) return FALSE
;
1413 size
= SendMessageW(listbox
, combo
? CB_GETLBTEXTLEN
: LB_GETTEXTLEN
, item
, 0 );
1414 if (size
== LB_ERR
) return FALSE
;
1416 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, (size
+2) * sizeof(WCHAR
) ))) return FALSE
;
1418 SendMessageW( listbox
, combo
? CB_GETLBTEXT
: LB_GETTEXT
, item
, (LPARAM
)buffer
);
1420 if ((ret
= (buffer
[0] == '['))) /* drive or directory */
1422 if (buffer
[1] == '-') /* drive */
1430 buffer
[strlenW(buffer
)-1] = '\\';
1436 /* Filenames without a dot extension must have one tacked at the end */
1437 if (strchrW(buffer
, '.') == NULL
)
1439 buffer
[strlenW(buffer
)+1] = '\0';
1440 buffer
[strlenW(buffer
)] = '.';
1447 if (len
> 0 && !WideCharToMultiByte( CP_ACP
, 0, ptr
, -1, (LPSTR
)str
, len
, 0, 0 ))
1448 ((LPSTR
)str
)[len
-1] = 0;
1450 else lstrcpynW( str
, ptr
, len
);
1451 HeapFree( GetProcessHeap(), 0, buffer
);
1452 TRACE("Returning %d %s\n", ret
, unicode
? debugstr_w(str
) : debugstr_a((LPSTR
)str
) );
1457 /* FUNCTIONS *****************************************************************/
1464 CreateDialogIndirectParamAorW(
1465 HINSTANCE hInstance
,
1466 LPCDLGTEMPLATE lpTemplate
,
1468 DLGPROC lpDialogFunc
,
1473 * This function might be obsolete since I don't think it is exported by NT
1474 * Also wine has one more parameter identifying weather it should call
1475 * the function with unicode or not
1477 return DIALOG_CreateIndirect( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, !Flags
, FALSE
);
1486 CreateDialogIndirectParamA(
1487 HINSTANCE hInstance
,
1488 LPCDLGTEMPLATE lpTemplate
,
1490 DLGPROC lpDialogFunc
,
1493 return CreateDialogIndirectParamAorW( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, 2 );
1502 CreateDialogIndirectParamW(
1503 HINSTANCE hInstance
,
1504 LPCDLGTEMPLATE lpTemplate
,
1506 DLGPROC lpDialogFunc
,
1509 return CreateDialogIndirectParamAorW( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, 0);
1519 HINSTANCE hInstance
,
1520 LPCSTR lpTemplateName
,
1522 DLGPROC lpDialogFunc
,
1528 if (!(hrsrc
= FindResourceA( hInstance
, lpTemplateName
, (LPCSTR
)RT_DIALOG
))) return 0;
1529 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1530 return CreateDialogIndirectParamA( hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
);
1540 HINSTANCE hInstance
,
1541 LPCWSTR lpTemplateName
,
1543 DLGPROC lpDialogFunc
,
1549 if (!(hrsrc
= FindResourceW( hInstance
, lpTemplateName
, (LPCWSTR
)RT_DIALOG
))) return 0;
1550 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1551 return CreateDialogIndirectParamW( hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
);
1566 DIALOGINFO
*dlgInfo
;
1568 BOOL result
= FALSE
;
1570 /* Perform DIALOGINFO initialization if not done */
1571 if(!(dlgInfo
= DIALOG_get_info( hDlg
, TRUE
))) return 0;
1573 SetWindowLongPtrW( hDlg
, DWLP_MSGRESULT
, 0 );
1575 if ((dlgproc
= (WNDPROC
)GetWindowLongPtrW( hDlg
, DWLP_DLGPROC
)))
1577 /* Call dialog procedure */
1578 result
= CallWindowProcA( dlgproc
, hDlg
, Msg
, wParam
, lParam
);
1581 if (!result
&& IsWindow(hDlg
))
1583 /* callback didn't process this message */
1597 case WM_ENTERMENULOOP
:
1598 case WM_LBUTTONDOWN
:
1599 case WM_NCLBUTTONDOWN
:
1600 return DEFDLG_Proc( hDlg
, Msg
, wParam
, lParam
, dlgInfo
);
1603 case WM_COMPAREITEM
:
1608 return DefWindowProcA( hDlg
, Msg
, wParam
, lParam
);
1611 return DEFDLG_Epilog(hDlg
, Msg
, result
);
1626 DIALOGINFO
*dlgInfo
;
1628 BOOL result
= FALSE
;
1630 /* Perform DIALOGINFO initialization if not done */
1631 if(!(dlgInfo
= DIALOG_get_info( hDlg
, TRUE
))) return 0;
1633 SetWindowLongPtrW( hDlg
, DWLP_MSGRESULT
, 0 );
1635 if ((dlgproc
= (WNDPROC
)GetWindowLongPtrW( hDlg
, DWLP_DLGPROC
)))
1637 /* Call dialog procedure */
1638 result
= CallWindowProcW( dlgproc
, hDlg
, Msg
, wParam
, lParam
);
1641 if (!result
&& IsWindow(hDlg
))
1643 /* callback didn't process this message */
1657 case WM_ENTERMENULOOP
:
1658 case WM_LBUTTONDOWN
:
1659 case WM_NCLBUTTONDOWN
:
1660 return DEFDLG_Proc( hDlg
, Msg
, wParam
, lParam
, dlgInfo
);
1663 case WM_COMPAREITEM
:
1668 return DefWindowProcW( hDlg
, Msg
, wParam
, lParam
);
1671 return DEFDLG_Epilog(hDlg
, Msg
, result
);
1680 DialogBoxIndirectParamAorW(
1681 HINSTANCE hInstance
,
1682 LPCDLGTEMPLATE hDialogTemplate
,
1684 DLGPROC lpDialogFunc
,
1689 * This function might be obsolete since I don't think it is exported by NT
1690 * Also wine has one more parameter identifying weather it should call
1691 * the function with unicode or not
1693 HWND hWnd
= DIALOG_CreateIndirect( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, !Flags
, TRUE
);
1694 if (hWnd
) return DIALOG_DoDialogBox( hWnd
, hWndParent
);
1704 DialogBoxIndirectParamA(
1705 HINSTANCE hInstance
,
1706 LPCDLGTEMPLATE hDialogTemplate
,
1708 DLGPROC lpDialogFunc
,
1711 return DialogBoxIndirectParamAorW( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, 2);
1720 DialogBoxIndirectParamW(
1721 HINSTANCE hInstance
,
1722 LPCDLGTEMPLATE hDialogTemplate
,
1724 DLGPROC lpDialogFunc
,
1727 return DialogBoxIndirectParamAorW( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, 0);
1737 HINSTANCE hInstance
,
1738 LPCSTR lpTemplateName
,
1740 DLGPROC lpDialogFunc
,
1746 //// ReactOS rev 33532
1747 if (!(hrsrc
= FindResourceA( hInstance
, lpTemplateName
, (LPCSTR
)RT_DIALOG
)) ||
1748 !(ptr
= LoadResource(hInstance
, hrsrc
)))
1750 SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND
);
1753 if (hWndParent
!= NULL
&& !IsWindow(hWndParent
))
1755 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
1758 hwnd
= DIALOG_CreateIndirect(hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
, FALSE
, TRUE
);
1759 if (hwnd
) return DIALOG_DoDialogBox(hwnd
, hWndParent
);
1770 HINSTANCE hInstance
,
1771 LPCWSTR lpTemplateName
,
1773 DLGPROC lpDialogFunc
,
1779 //// ReactOS rev 33532
1780 if (!(hrsrc
= FindResourceW( hInstance
, lpTemplateName
, (LPCWSTR
)RT_DIALOG
)) ||
1781 !(ptr
= LoadResource(hInstance
, hrsrc
)))
1783 SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND
);
1786 if (hWndParent
!= NULL
&& !IsWindow(hWndParent
))
1788 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
1791 hwnd
= DIALOG_CreateIndirect(hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
, TRUE
, TRUE
);
1792 if (hwnd
) return DIALOG_DoDialogBox(hwnd
, hWndParent
);
1809 return DIALOG_DlgDirListA( hDlg
, lpPathSpec
, nIDListBox
, nIDStaticPath
, uFileType
, FALSE
);
1818 DlgDirListComboBoxA(
1825 return DIALOG_DlgDirListA( hDlg
, lpPathSpec
, nIDComboBox
, nIDStaticPath
, uFiletype
, TRUE
);
1834 DlgDirListComboBoxW(
1841 return DIALOG_DlgDirListW( hDlg
, lpPathSpec
, nIDComboBox
, nIDStaticPath
, uFiletype
, TRUE
);
1857 return DIALOG_DlgDirListW( hDlg
, lpPathSpec
, nIDListBox
, nIDStaticPath
, uFileType
, FALSE
);
1866 DlgDirSelectComboBoxExA(
1872 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDComboBox
, FALSE
, TRUE
);
1881 DlgDirSelectComboBoxExW(
1887 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDComboBox
, TRUE
, TRUE
);
1902 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDListBox
, FALSE
, FALSE
);
1917 return DIALOG_DlgDirSelect( hDlg
, lpString
, nCount
, nIDListBox
, TRUE
, FALSE
);
1930 BOOL wasEnabled
= TRUE
;
1931 DIALOGINFO
* dlgInfo
;
1934 if (!(dlgInfo
= GETDLGINFO(hDlg
))) return FALSE
;
1936 dlgInfo
->idResult
= nResult
;
1937 dlgInfo
->flags
|= DF_END
;
1938 wasEnabled
= (dlgInfo
->flags
& DF_OWNERENABLED
);
1940 if (wasEnabled
&& (owner
= GetWindow( hDlg
, GW_OWNER
)))
1941 DIALOG_EnableOwner( owner
);
1943 /* Windows sets the focus to the dialog itself in EndDialog */
1945 if (IsChild(hDlg
, GetFocus()))
1948 /* Don't have to send a ShowWindow(SW_HIDE), just do
1949 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1951 SetWindowPos(hDlg
, NULL
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
1952 | SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_HIDEWINDOW
);
1954 if (hDlg
== GetActiveWindow()) WinPosActivateOtherWindow( hDlg
);
1956 /* unblock dialog loop */
1957 PostMessageA(hDlg
, WM_NULL
, 0, 0);
1967 GetDialogBaseUnits(VOID
)
1976 if ((hdc
= GetDC(0)))
1978 size
.cx
= GdiGetCharDimensions( hdc
, NULL
, &size
.cy
);
1979 if (size
.cx
) units
= MAKELONG( size
.cx
, size
.cy
);
1980 ReleaseDC( 0, hdc
);
1995 return GetWindowLongPtrW( hwndCtl
, GWLP_ID
);
2009 HWND
*list
= WIN_ListChildren(hDlg
);
2012 if (!list
) return 0;
2014 for (i
= 0; list
[i
]; i
++) if (GetWindowLongPtrW(list
[i
], GWLP_ID
) == nIDDlgItem
) break;
2016 HeapFree(GetProcessHeap(), 0, list
);
2036 if (lpTranslated
) *lpTranslated
= FALSE
;
2037 if (!SendDlgItemMessageA(hDlg
, nIDDlgItem
, WM_GETTEXT
, sizeof(str
), (LPARAM
)str
))
2041 result
= strtol( str
, &endptr
, 10 );
2042 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
2045 if (((result
== 0) || (result
== 0xFFFFFFFF))/* && (errno == ERANGE) */)
2050 result
= strtoul( str
, &endptr
, 10 );
2051 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
2054 if ((result
== 0xFFFFFFFF)/* && (errno == ERANGE) */) return 0;
2056 if (lpTranslated
) *lpTranslated
= TRUE
;
2057 return (UINT
)result
;
2072 if (lpString
&& (nMaxCount
> 0)) lpString
[0] = '\0';
2073 return (UINT
)SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
2088 if (lpString
&& (nMaxCount
> 0)) lpString
[0] = '\0';
2089 return (UINT
)SendDlgItemMessageW( hDlg
, nIDDlgItem
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
2097 GetNextDlgGroupItem(
2102 HWND hwnd
, hwndNext
, retvalue
, hwndLastGroup
= 0;
2104 BOOL fSkipping
=FALSE
;
2106 if (hDlg
== hCtl
) hCtl
= NULL
;
2107 if (!hCtl
&& bPrevious
) return 0;
2109 /* if the hwndCtrl is the child of the control in the hwndDlg,
2110 * then the hwndDlg has to be the parent of the hwndCtrl */
2114 if (!IsChild (hDlg
, hCtl
)) return 0;
2115 /* Make sure hwndCtrl is a top-level child */
2120 /* No ctrl specified -> start from the beginning */
2121 if (!(hCtl
= GetWindow( hDlg
, GW_CHILD
))) return 0;
2122 /* MSDN is wrong. fPrevious does not result in the last child */
2124 /* No ctrl specified -> start from the beginning */
2125 if (!(hCtl
= GetWindow( hDlg
, GW_CHILD
))) return 0;
2127 /* MSDN is wrong. fPrevious does not result in the last child */
2129 /* Maybe that first one is valid. If so then we don't want to skip it*/
2130 if ((GetWindowLongPtrW( hCtl
, GWL_STYLE
) & (WS_VISIBLE
|WS_DISABLED
)) == WS_VISIBLE
)
2137 /* Always go forward around the group and list of controls; for the
2138 * previous control keep track; for the next break when you find one
2142 while (hwndNext
= GetWindow (hwnd
, GW_HWNDNEXT
),
2147 /* Climb out until there is a next sibling of the ancestor or we
2148 * reach the top (in which case we loop back to the start)
2150 if (hDlg
== GetParent (hwnd
))
2152 /* Wrap around to the beginning of the list, within the same
2153 * group. (Once only)
2155 if (fLooped
) goto end
;
2157 hwndNext
= GetWindow (hDlg
, GW_CHILD
);
2161 hwnd
= GetParent (hwnd
);
2162 hwndNext
= GetWindow (hwnd
, GW_HWNDNEXT
);
2167 /* Wander down the leading edge of controlparents */
2168 while ( (GetWindowLongPtrW (hwnd
, GWL_EXSTYLE
) & WS_EX_CONTROLPARENT
) &&
2169 ((GetWindowLongPtrW (hwnd
, GWL_STYLE
) & (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
) &&
2170 (hwndNext
= GetWindow (hwnd
, GW_CHILD
)))
2172 /* Question. If the control is a control parent but either has no
2173 * children or is not visible/enabled then if it has a WS_GROUP does
2174 * it count? For that matter does it count anyway?
2175 * I believe it doesn't count.
2178 if ((GetWindowLongPtrW (hwnd
, GWL_STYLE
) & WS_GROUP
))
2180 hwndLastGroup
= hwnd
;
2183 /* Look for the beginning of the group */
2190 if (!fSkipping
) break;
2191 if (hwndLastGroup
== hwnd
) break;
2192 hwnd
= hwndLastGroup
;
2198 (GetWindowLongPtrW (hwnd
, GWL_STYLE
) & (WS_VISIBLE
|WS_DISABLED
)) ==
2202 if (!bPrevious
) break;
2220 /* Undocumented but tested under Win2000 and WinME */
2221 if (hDlg
== hCtl
) hCtl
= NULL
;
2223 /* Contrary to MSDN documentation, tested under Win2000 and WinME
2224 * NB GetLastError returns whatever was set before the function was
2227 if (!hCtl
&& bPrevious
) return 0;
2229 return DIALOG_GetNextTabItem(hDlg
, hDlg
, hCtl
, bPrevious
);
2240 return IsDialogMessageW(hDlg
, lpMsg
);
2244 /***********************************************************************
2245 * DIALOG_FixOneChildOnChangeFocus
2247 * Callback helper for DIALOG_FixChildrenOnChangeFocus
2250 static BOOL CALLBACK
DIALOG_FixOneChildOnChangeFocus (HWND hwndChild
,
2253 /* If a default pushbutton then no longer default */
2254 if (DLGC_DEFPUSHBUTTON
& SendMessageW (hwndChild
, WM_GETDLGCODE
, 0, 0))
2255 SendMessageW (hwndChild
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
2259 /***********************************************************************
2260 * DIALOG_FixChildrenOnChangeFocus
2262 * Following the change of focus that occurs for example after handling
2263 * a WM_KEYDOWN VK_TAB in IsDialogMessage, some tidying of the dialog's
2264 * children may be required.
2266 static void DIALOG_FixChildrenOnChangeFocus (HWND hwndDlg
, HWND hwndNext
)
2268 INT dlgcode_next
= SendMessageW (hwndNext
, WM_GETDLGCODE
, 0, 0);
2269 /* INT dlgcode_dlg = SendMessageW (hwndDlg, WM_GETDLGCODE, 0, 0); */
2270 /* Windows does ask for this. I don't know why yet */
2272 EnumChildWindows (hwndDlg
, DIALOG_FixOneChildOnChangeFocus
, 0);
2274 /* If the button that is getting the focus WAS flagged as the default
2275 * pushbutton then ask the dialog what it thinks the default is and
2276 * set that in the default style.
2278 if (dlgcode_next
& DLGC_DEFPUSHBUTTON
)
2280 DWORD def_id
= SendMessageW (hwndDlg
, DM_GETDEFID
, 0, 0);
2281 if (HIWORD(def_id
) == DC_HASDEFID
)
2284 def_id
= LOWORD(def_id
);
2285 hwndDef
= GetDlgItem (hwndDlg
, def_id
);
2288 INT dlgcode_def
= SendMessageW (hwndDef
, WM_GETDLGCODE
, 0, 0);
2289 /* I know that if it is a button then it should already be a
2290 * UNDEFPUSHBUTTON, since we have just told the buttons to
2291 * change style. But maybe they ignored our request
2293 if ((dlgcode_def
& DLGC_BUTTON
) &&
2294 (dlgcode_def
& DLGC_UNDEFPUSHBUTTON
))
2296 SendMessageW (hwndDef
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
2301 else if ((dlgcode_next
& DLGC_BUTTON
) && (dlgcode_next
& DLGC_UNDEFPUSHBUTTON
))
2303 SendMessageW (hwndNext
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
2304 /* I wonder why it doesn't send a DM_SETDEFID */
2319 if (CallMsgFilterW( lpMsg
, MSGF_DIALOGBOX
)) return TRUE
;
2321 if (hDlg
== GetDesktopWindow()) return FALSE
;
2322 if ((hDlg
!= lpMsg
->hwnd
) && !IsChild( hDlg
, lpMsg
->hwnd
)) return FALSE
;
2324 hDlg
= DIALOG_FindMsgDestination(hDlg
);
2326 switch(lpMsg
->message
)
2329 dlgCode
= SendMessageW( lpMsg
->hwnd
, WM_GETDLGCODE
, lpMsg
->wParam
, (LPARAM
)lpMsg
);
2330 if (dlgCode
& DLGC_WANTMESSAGE
) break;
2332 switch(lpMsg
->wParam
)
2335 if (!(dlgCode
& DLGC_WANTTAB
))
2337 SendMessageW(hDlg
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_CLEAR
, UISF_HIDEFOCUS
), 0);
2339 /* I am not sure under which circumstances the TAB is handled
2340 * each way. All I do know is that it does not always simply
2341 * send WM_NEXTDLGCTL. (Personally I have never yet seen it
2342 * do so but I presume someone has)
2344 if (GETDLGINFO(hDlg
))
2345 SendMessageW( hDlg
, WM_NEXTDLGCTL
, (GetKeyState(VK_SHIFT
) & 0x8000), 0 );
2348 /* It would appear that GetNextDlgTabItem can handle being
2349 * passed hwndDlg rather than NULL but that is undocumented
2350 * so let's do it properly
2352 HWND hwndFocus
= GetFocus();
2353 HWND hwndNext
= GetNextDlgTabItem (hDlg
,
2354 hwndFocus
== hDlg
? NULL
: hwndFocus
,
2355 GetKeyState (VK_SHIFT
) & 0x8000);
2358 dlgCode
= SendMessageW (hwndNext
, WM_GETDLGCODE
,
2359 lpMsg
->wParam
, (LPARAM
)lpMsg
);
2360 if (dlgCode
& DLGC_HASSETSEL
)
2362 INT maxlen
= 1 + SendMessageW (hwndNext
, WM_GETTEXTLENGTH
, 0, 0);
2363 WCHAR
*buffer
= HeapAlloc (GetProcessHeap(), 0, maxlen
* sizeof(WCHAR
));
2367 SendMessageW (hwndNext
, WM_GETTEXT
, maxlen
, (LPARAM
) buffer
);
2368 length
= strlenW (buffer
);
2369 HeapFree (GetProcessHeap(), 0, buffer
);
2370 SendMessageW (hwndNext
, EM_SETSEL
, 0, length
);
2373 SetFocus (hwndNext
);
2374 DIALOG_FixChildrenOnChangeFocus (hDlg
, hwndNext
);
2387 if (!(dlgCode
& DLGC_WANTARROWS
))
2389 BOOL fPrevious
= (lpMsg
->wParam
== VK_LEFT
|| lpMsg
->wParam
== VK_UP
);
2390 HWND hwndNext
= GetNextDlgGroupItem (hDlg
, GetFocus(), fPrevious
);
2391 SendMessageW( hDlg
, WM_NEXTDLGCTL
, (WPARAM
)hwndNext
, 1 );
2398 SendMessageW( hDlg
, WM_COMMAND
, IDCANCEL
, (LPARAM
)GetDlgItem( hDlg
, IDCANCEL
) );
2405 if ((GetFocus() == lpMsg
->hwnd
) &&
2406 (SendMessageW (lpMsg
->hwnd
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
2408 SendMessageW (hDlg
, WM_COMMAND
, MAKEWPARAM (GetDlgCtrlID(lpMsg
->hwnd
),BN_CLICKED
), (LPARAM
)lpMsg
->hwnd
);
2410 else if (DC_HASDEFID
== HIWORD(dw
= SendMessageW (hDlg
, DM_GETDEFID
, 0, 0)))
2412 HWND hwndDef
= GetDlgItem(hDlg
, LOWORD(dw
));
2413 if (hwndDef
? IsWindowEnabled(hwndDef
) : LOWORD(dw
)==IDOK
)
2414 SendMessageW( hDlg
, WM_COMMAND
, MAKEWPARAM( LOWORD(dw
), BN_CLICKED
), (LPARAM
)hwndDef
);
2418 SendMessageW( hDlg
, WM_COMMAND
, IDOK
, (LPARAM
)GetDlgItem( hDlg
, IDOK
) );
2427 /* FIXME Under what circumstances does WM_GETDLGCODE get sent?
2428 * It does NOT get sent in the test program I have
2430 dlgCode
= SendMessageW( lpMsg
->hwnd
, WM_GETDLGCODE
, lpMsg
->wParam
, (LPARAM
)lpMsg
);
2431 if (dlgCode
& (DLGC_WANTCHARS
|DLGC_WANTMESSAGE
)) break;
2432 if (lpMsg
->wParam
== '\t' && (dlgCode
& DLGC_WANTTAB
)) break;
2436 if (DIALOG_IsAccelerator( lpMsg
->hwnd
, hDlg
, lpMsg
->wParam
))
2438 /* don't translate or dispatch */
2444 /* If the ALT key is being pressed display the keyboard cues */
2445 if (lpMsg
->lParam
& (1 << 29))
2446 SendMessageW(hDlg
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_CLEAR
, UISF_HIDEACCEL
| UISF_HIDEFOCUS
), 0);
2450 /* If the ALT key is being pressed display the keyboard cues */
2451 if (lpMsg
->wParam
== SC_KEYMENU
)
2453 SendMessageW(hDlg
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_CLEAR
, UISF_HIDEACCEL
| UISF_HIDEFOCUS
), 0);
2458 TranslateMessage( lpMsg
);
2459 DispatchMessageW( lpMsg
);
2473 return (UINT
)SendDlgItemMessageW( hDlg
, nIDButton
, BM_GETCHECK
, 0, 0 );
2486 DIALOGINFO
* dlgInfo
;
2487 if (!(dlgInfo
= GETDLGINFO(hDlg
))) return FALSE
;
2488 lpRect
->left
= MulDiv(lpRect
->left
, dlgInfo
->xBaseUnit
, 4);
2489 lpRect
->right
= MulDiv(lpRect
->right
, dlgInfo
->xBaseUnit
, 4);
2490 lpRect
->top
= MulDiv(lpRect
->top
, dlgInfo
->yBaseUnit
, 8);
2491 lpRect
->bottom
= MulDiv(lpRect
->bottom
, dlgInfo
->yBaseUnit
, 8);
2501 SendDlgItemMessageA(
2508 HWND hwndCtrl
= GetDlgItem( hDlg
, nIDDlgItem
);
2509 if (hwndCtrl
) return SendMessageA( hwndCtrl
, Msg
, wParam
, lParam
);
2519 SendDlgItemMessageW(
2526 HWND hwndCtrl
= GetDlgItem( hDlg
, nIDDlgItem
);
2527 if (hwndCtrl
) return SendMessageW( hwndCtrl
, Msg
, wParam
, lParam
);
2545 if (bSigned
) sprintf( str
, "%d", (INT
)uValue
);
2546 else sprintf( str
, "%u", uValue
);
2547 SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)str
);
2562 return SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2576 return SendDlgItemMessageW( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2590 SendDlgItemMessageW( hDlg
, nIDButton
, BM_SETCHECK
, uCheck
, 0 );
2594 static BOOL CALLBACK
CheckRB(HWND hwnd
, LPARAM lParam
)
2596 LONG lChildID
= GetWindowLongPtrW(hwnd
, GWLP_ID
);
2597 RADIOGROUP
*lpRadioGroup
= (RADIOGROUP
*)lParam
;
2599 if((lChildID
>= lpRadioGroup
->firstID
) &&
2600 (lChildID
<= lpRadioGroup
->lastID
))
2602 if (lChildID
== lpRadioGroup
->checkID
)
2604 SendMessageW(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
2608 SendMessageW(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
2626 RADIOGROUP radioGroup
;
2628 radioGroup
.firstID
= nIDFirstButton
;
2629 radioGroup
.lastID
= nIDLastButton
;
2630 radioGroup
.checkID
= nIDCheckButton
;
2632 return EnumChildWindows(hDlg
, CheckRB
, (LPARAM
)&radioGroup
);