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.
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/windows/dialog.c
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 * Thomas Weidenmueller (w3seek@users.sourceforge.net)
26 * Steven Edwards (Steven_Ed4153@yahoo.com)
28 * 07-26-2003 Code ported from wine
29 * 09-05-2001 CSH Created
32 /* INCLUDES ******************************************************************/
36 #include <wine/debug.h>
37 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
39 /* MACROS/DEFINITIONS ********************************************************/
42 #define DF_OWNERENABLED 0x0002
43 #define CW_USEDEFAULT16 ((short)0x8000)
44 #define DWLP_ROS_DIALOGINFO (DWLP_USER+sizeof(ULONG_PTR))
45 #define GETDLGINFO(hwnd) DIALOG_get_info(hwnd, FALSE)
46 #define SETDLGINFO(hwnd, info) SetWindowLongPtrW((hwnd), DWLP_ROS_DIALOGINFO, (LONG_PTR)(info))
47 #define GET_WORD(ptr) (*(WORD *)(ptr))
48 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
49 #define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom))))
50 #define MAKEINTATOMW(atom) ((LPCWSTR)((ULONG_PTR)((WORD)(atom))))
51 #define DIALOG_CLASS_ATOMA MAKEINTATOMA(32770) /* Dialog */
52 #define DIALOG_CLASS_ATOMW MAKEINTATOMW(32770) /* Dialog */
54 void WINAPI
WinPosActivateOtherWindow(HWND hwnd
);
56 /* INTERNAL STRUCTS **********************************************************/
58 /* Dialog info structure */
61 HWND hwndFocus
; /* Current control with focus */
62 HFONT hUserFont
; /* Dialog font */
63 HMENU hMenu
; /* Dialog menu */
64 UINT xBaseUnit
; /* Dialog units (depends on the font) */
66 INT idResult
; /* EndDialog() result / default pushbutton ID */
67 UINT flags
; /* EndDialog() called for this dialog */
70 /* Dialog control information */
108 /* GetDlgItem structure */
115 /* CheckRadioButton structure */
124 /*********************************************************************
125 * dialog class descriptor
127 const struct builtin_class_descr DIALOG_builtin_class
=
129 DIALOG_CLASS_ATOMW
, /* name */
130 CS_SAVEBITS
| CS_DBLCLKS
, /* style */
131 (WNDPROC
) DefDlgProcW
, /* procW */
132 (WNDPROC
) DefDlgProcA
, /* procA */
133 DLGWINDOWEXTRA
, /* extra */
134 (LPCWSTR
) IDC_ARROW
, /* cursor */
139 /* INTERNAL FUNCTIONS ********************************************************/
141 /***********************************************************************
144 * Get the DIALOGINFO structure of a window, allocating it if needed
145 * and 'create' is TRUE.
147 DIALOGINFO
* DIALOG_get_info( HWND hWnd
, BOOL create
)
150 DIALOGINFO
* dlgInfo
= (DIALOGINFO
*)GetWindowLongPtrW( hWnd
, DWLP_ROS_DIALOGINFO
);
152 if(!dlgInfo
&& create
)
154 pWindow
= ValidateHwnd( hWnd
);
156 if (pWindow
&& pWindow
->ExtraDataSize
>= DLGWINDOWEXTRA
&& hWnd
!= GetDesktopWindow())
158 if (!(dlgInfo
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*dlgInfo
) )))
161 SETDLGINFO( hWnd
, dlgInfo
);
163 NtUserSetWindowFNID( hWnd
, FNID_DIALOG
);
173 /***********************************************************************
176 * Helper function for modal dialogs to enable again the
177 * owner of the dialog box.
179 void DIALOG_EnableOwner( HWND hOwner
)
181 /* Owner must be a top-level window */
183 hOwner
= GetAncestor( hOwner
, GA_ROOT
);
185 EnableWindow( hOwner
, TRUE
);
188 /***********************************************************************
189 * DIALOG_DisableOwner
191 * Helper function for modal dialogs to disable the
192 * owner of the dialog box. Returns TRUE if owner was enabled.
194 BOOL
DIALOG_DisableOwner( HWND hOwner
)
196 /* Owner must be a top-level window */
198 hOwner
= GetAncestor( hOwner
, GA_ROOT
);
199 if (!hOwner
) return FALSE
;
200 if (IsWindowEnabled( hOwner
))
202 EnableWindow( hOwner
, FALSE
);
209 /***********************************************************************
210 * DIALOG_GetControl32
212 * Return the class and text of the control pointed to by ptr,
213 * fill the header structure and return a pointer to the next control.
215 static const WORD
*DIALOG_GetControl32( const WORD
*p
, DLG_CONTROL_INFO
*info
,
220 info
->helpId
= GET_DWORD(p
); p
+= 2;
221 info
->exStyle
= GET_DWORD(p
); p
+= 2;
222 info
->style
= GET_DWORD(p
); p
+= 2;
227 info
->style
= GET_DWORD(p
); p
+= 2;
228 info
->exStyle
= GET_DWORD(p
); p
+= 2;
230 info
->x
= GET_WORD(p
); p
++;
231 info
->y
= GET_WORD(p
); p
++;
232 info
->cx
= GET_WORD(p
); p
++;
233 info
->cy
= GET_WORD(p
); p
++;
237 /* id is a DWORD for DIALOGEX */
238 info
->id
= GET_DWORD(p
);
243 info
->id
= GET_WORD(p
);
247 if (GET_WORD(p
) == 0xffff)
249 static const WCHAR class_names
[6][10] =
251 { 'B','u','t','t','o','n', }, /* 0x80 */
252 { 'E','d','i','t', }, /* 0x81 */
253 { 'S','t','a','t','i','c', }, /* 0x82 */
254 { 'L','i','s','t','B','o','x', }, /* 0x83 */
255 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
256 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
258 WORD id
= GET_WORD(p
+1);
259 /* Windows treats dialog control class ids 0-5 same way as 0x80-0x85 */
260 if ((id
>= 0x80) && (id
<= 0x85)) id
-= 0x80;
262 info
->className
= class_names
[id
];
265 info
->className
= NULL
;
266 /* FIXME: load other classes here? */
272 info
->className
= (LPCWSTR
)p
;
273 p
+= wcslen( info
->className
) + 1;
276 if (GET_WORD(p
) == 0xffff) /* Is it an integer id? */
278 info
->windowName
= HeapAlloc( GetProcessHeap(), 0, sizeof(L
"#65535") );
279 if (info
->windowName
!= NULL
)
281 swprintf((LPWSTR
)info
->windowName
, L
"#%d", GET_WORD(p
+ 1));
282 info
->windowNameFree
= TRUE
;
286 info
->windowNameFree
= FALSE
;
292 info
->windowName
= (LPCWSTR
)p
;
293 info
->windowNameFree
= FALSE
;
294 p
+= wcslen( info
->windowName
) + 1;
300 p
+= GET_WORD(p
) / sizeof(WORD
);
302 else info
->data
= NULL
;
305 /* Next control is on dword boundary */
306 return (const WORD
*)((((int)p
) + 3) & ~3);
309 /***********************************************************************
310 * DIALOG_CreateControls32
312 * Create the control windows for a dialog.
314 static BOOL
DIALOG_CreateControls32( HWND hwnd
, LPCSTR
template, const DLG_TEMPLATE
*dlgTemplate
,
315 HINSTANCE hInst
, BOOL unicode
)
317 DIALOGINFO
* dlgInfo
;
318 DLG_CONTROL_INFO info
;
319 HWND hwndCtrl
, hwndDefButton
= 0;
320 INT items
= dlgTemplate
->nbItems
;
322 if (!(dlgInfo
= GETDLGINFO(hwnd
))) return FALSE
;
326 template = (LPCSTR
)DIALOG_GetControl32( (WORD
*)template, &info
,
327 dlgTemplate
->dialogEx
);
329 if (info
.style
& WS_BORDER
)
331 info
.style
&= ~WS_BORDER
;
332 info
.exStyle
|= WS_EX_CLIENTEDGE
;
336 hwndCtrl
= CreateWindowExW( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
337 info
.className
, info
.windowName
,
338 info
.style
| WS_CHILD
,
339 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
340 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
341 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
342 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
343 hwnd
, (HMENU
)info
.id
,
344 hInst
, (LPVOID
)info
.data
);
348 LPSTR
class = (LPSTR
)info
.className
;
349 LPSTR caption
= (LPSTR
)info
.windowName
;
353 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, info
.className
, -1, NULL
, 0, NULL
, NULL
);
354 class = HeapAlloc( GetProcessHeap(), 0, len
);
356 WideCharToMultiByte( CP_ACP
, 0, info
.className
, -1, class, len
, NULL
, NULL
);
360 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, info
.windowName
, -1, NULL
, 0, NULL
, NULL
);
361 caption
= HeapAlloc( GetProcessHeap(), 0, len
);
363 WideCharToMultiByte( CP_ACP
, 0, info
.windowName
, -1, caption
, len
, NULL
, NULL
);
366 if (class != NULL
&& caption
!= NULL
)
368 hwndCtrl
= CreateWindowExA( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
369 class, caption
, info
.style
| WS_CHILD
,
370 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
371 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
372 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
373 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
374 hwnd
, (HMENU
)info
.id
,
375 hInst
, (LPVOID
)info
.data
);
379 if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
380 if (HIWORD(caption
)) HeapFree( GetProcessHeap(), 0, caption
);
383 if (info
.windowNameFree
)
385 HeapFree( GetProcessHeap(), 0, (LPVOID
)info
.windowName
);
390 if (dlgTemplate
->style
& DS_NOFAILCREATE
) continue;
394 /* Send initialisation messages to the control */
395 if (dlgInfo
->hUserFont
) SendMessageW( hwndCtrl
, WM_SETFONT
,
396 (WPARAM
)dlgInfo
->hUserFont
, 0 );
397 if (SendMessageW(hwndCtrl
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
)
399 /* If there's already a default push-button, set it back */
400 /* to normal and use this one instead. */
402 SendMessageW( hwndDefButton
, BM_SETSTYLE
, BS_PUSHBUTTON
, FALSE
);
403 hwndDefButton
= hwndCtrl
;
404 dlgInfo
->idResult
= GetWindowLongPtrA( hwndCtrl
, GWLP_ID
);
410 /***********************************************************************
411 * DIALOG_FindMsgDestination
413 * The messages that IsDialogMessage sends may not go to the dialog
414 * calling IsDialogMessage if that dialog is a child, and it has the
415 * DS_CONTROL style set.
416 * We propagate up until we hit one that does not have DS_CONTROL, or
417 * whose parent is not a dialog.
419 * This is undocumented behaviour.
421 static HWND
DIALOG_FindMsgDestination( HWND hwndDlg
)
423 while (GetWindowLongA(hwndDlg
, GWL_STYLE
) & DS_CONTROL
)
425 HWND hParent
= GetParent(hwndDlg
);
428 if (!IsWindow(hParent
)) break;
430 if (!GETDLGINFO(hParent
)) /* TODO: Correct? */
441 /***********************************************************************
442 * DIALOG_IsAccelerator
444 static BOOL
DIALOG_IsAccelerator( HWND hwnd
, HWND hwndDlg
, WPARAM wParam
)
446 HWND hwndControl
= hwnd
;
453 DWORD style
= GetWindowLongW( hwndControl
, GWL_STYLE
);
454 if ((style
& (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
)
456 dlgCode
= SendMessageA( hwndControl
, WM_GETDLGCODE
, 0, 0 );
457 if ( (dlgCode
& (DLGC_BUTTON
| DLGC_STATIC
)) &&
458 GetWindowTextW( hwndControl
, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
460 /* find the accelerator key */
461 LPWSTR p
= buffer
- 2;
465 p
= wcschr( p
+ 2, '&' );
467 while (p
!= NULL
&& p
[1] == '&');
469 /* and check if it's the one we're looking for */
470 /* FIXME: usage of towupper correct? */
471 if (p
!= NULL
&& towupper( p
[1] ) == towupper( 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 NtUserShowWindow( hwnd
, SW_SHOWNORMAL
);
542 if (!(GetWindowLongW( 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 -1;
551 if (!(dlgInfo
->flags
& DF_END
) && !IsDialogMessageW( hwnd
, &msg
))
553 TranslateMessage( &msg
);
554 DispatchMessageW( &msg
);
556 if (dlgInfo
->flags
& DF_END
) break;
559 if (dlgInfo
->flags
& DF_OWNERENABLED
) DIALOG_EnableOwner( owner
);
560 retval
= dlgInfo
->idResult
;
561 NtUserDestroyWindow( hwnd
);
565 /***********************************************************************
566 * DIALOG_ParseTemplate32
568 * Fill a DLG_TEMPLATE structure from the dialog template, and return
569 * a pointer to the first control.
571 static LPCSTR
DIALOG_ParseTemplate32( LPCSTR
template, DLG_TEMPLATE
* result
)
573 const WORD
*p
= (const WORD
*)template;
577 signature
= GET_WORD(p
); p
++;
578 dlgver
= GET_WORD(p
); p
++;
580 if (signature
== 1 && dlgver
== 0xffff) /* DIALOGEX resource */
582 result
->dialogEx
= TRUE
;
583 result
->helpId
= GET_DWORD(p
); p
+= 2;
584 result
->exStyle
= GET_DWORD(p
); p
+= 2;
585 result
->style
= GET_DWORD(p
); p
+= 2;
589 result
->style
= GET_DWORD(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
++;
600 /* Get the menu name */
605 result
->menuName
= NULL
;
609 result
->menuName
= (LPCWSTR
)(UINT
)GET_WORD( p
+ 1 );
613 result
->menuName
= (LPCWSTR
)p
;
614 p
+= wcslen( result
->menuName
) + 1;
618 /* Get the class name */
623 result
->className
= DIALOG_CLASS_ATOMW
;
627 result
->className
= (LPCWSTR
)(UINT
)GET_WORD( p
+ 1 );
631 result
->className
= (LPCWSTR
)p
;
632 p
+= wcslen( result
->className
) + 1;
636 /* Get the window caption */
638 result
->caption
= (LPCWSTR
)p
;
639 p
+= wcslen( result
->caption
) + 1;
641 /* Get the font name */
643 result
->pointSize
= 0;
644 result
->weight
= FW_DONTCARE
;
645 result
->italic
= FALSE
;
646 result
->faceName
= NULL
;
648 if (result
->style
& DS_SETFONT
)
650 result
->pointSize
= GET_WORD(p
);
652 if (result
->dialogEx
)
654 result
->weight
= GET_WORD(p
); p
++;
655 result
->italic
= LOBYTE(GET_WORD(p
)); p
++;
657 result
->faceName
= (LPCWSTR
)p
;
658 p
+= wcslen( result
->faceName
) + 1;
661 /* First control is on dword boundary */
662 return (LPCSTR
)((((UINT_PTR
)p
) + 3) & ~3);
665 /***********************************************************************
666 * DIALOG_CreateIndirect
667 * Creates a dialog box window
669 * modal = TRUE if we are called from a modal dialog box.
670 * (it's more compatible to do it here, as under Windows the owner
671 * is never disabled if the dialog fails because of an invalid template)
673 static HWND
DIALOG_CreateIndirect( HINSTANCE hInst
, LPCVOID dlgTemplate
,
674 HWND owner
, DLGPROC dlgProc
, LPARAM param
,
675 BOOL unicode
, BOOL modal
)
679 DLG_TEMPLATE
template;
680 DIALOGINFO
* dlgInfo
= NULL
;
681 DWORD units
= GetDialogBaseUnits();
682 BOOL ownerEnabled
= TRUE
;
686 UINT xBaseUnit
= LOWORD(units
);
687 UINT yBaseUnit
= HIWORD(units
);
689 /* Parse dialog template */
691 if (!dlgTemplate
) return 0;
692 dlgTemplate
= DIALOG_ParseTemplate32( dlgTemplate
, &template );
696 if (template.menuName
) hMenu
= LoadMenuW( hInst
, template.menuName
);
698 /* Create custom font if needed */
700 if (template.style
& DS_SETFONT
)
702 /* We convert the size to pixels and then make it -ve. This works
703 * for both +ve and -ve template.pointSize */
707 pixels
= MulDiv(template.pointSize
, GetDeviceCaps(dc
, LOGPIXELSY
), 72);
708 hUserFont
= CreateFontW( -pixels
, 0, 0, 0, template.weight
,
709 template.italic
, FALSE
, FALSE
, DEFAULT_CHARSET
, 0, 0,
710 PROOF_QUALITY
, FF_DONTCARE
,
715 HFONT hOldFont
= SelectObject( dc
, hUserFont
);
716 charSize
.cx
= GdiGetCharDimensions( dc
, NULL
, &charSize
.cy
);
719 xBaseUnit
= charSize
.cx
;
720 yBaseUnit
= charSize
.cy
;
722 SelectObject( dc
, hOldFont
);
725 TRACE("units = %d,%d\n", xBaseUnit
, yBaseUnit
);
728 /* Create dialog main window */
730 rect
.left
= rect
.top
= 0;
731 rect
.right
= MulDiv(template.cx
, xBaseUnit
, 4);
732 rect
.bottom
= MulDiv(template.cy
, yBaseUnit
, 8);
733 if (template.style
& WS_CHILD
)
734 template.style
&= ~(WS_CAPTION
|WS_SYSMENU
);
735 if (template.style
& DS_MODALFRAME
)
736 template.exStyle
|= WS_EX_DLGMODALFRAME
;
737 if (template.style
& DS_CONTROL
)
738 template.exStyle
|= WS_EX_CONTROLPARENT
;
739 AdjustWindowRectEx( &rect
, template.style
, (hMenu
!= 0), template.exStyle
);
740 rect
.right
-= rect
.left
;
741 rect
.bottom
-= rect
.top
;
743 if (template.x
== CW_USEDEFAULT16
)
745 rect
.left
= rect
.top
= CW_USEDEFAULT
;
749 if (template.style
& DS_CENTER
)
751 rect
.left
= (GetSystemMetrics(SM_CXSCREEN
) - rect
.right
) / 2;
752 rect
.top
= (GetSystemMetrics(SM_CYSCREEN
) - rect
.bottom
) / 2;
756 rect
.left
+= MulDiv(template.x
, xBaseUnit
, 4);
757 rect
.top
+= MulDiv(template.y
, yBaseUnit
, 8);
758 if( !(template.style
& (WS_CHILD
|DS_ABSALIGN
)) )
759 ClientToScreen( owner
, (POINT
*)&rect
);
761 if ( !(template.style
& WS_CHILD
) )
765 /* try to fit it into the desktop */
767 if( (dX
= rect
.left
+ rect
.right
+ GetSystemMetrics(SM_CXDLGFRAME
)
768 - GetSystemMetrics(SM_CXSCREEN
)) > 0 ) rect
.left
-= dX
;
769 if( (dY
= rect
.top
+ rect
.bottom
+ GetSystemMetrics(SM_CYDLGFRAME
)
770 - GetSystemMetrics(SM_CYSCREEN
)) > 0 ) rect
.top
-= dY
;
771 if( rect
.left
< 0 ) rect
.left
= 0;
772 if( rect
.top
< 0 ) rect
.top
= 0;
778 ownerEnabled
= DIALOG_DisableOwner( owner
);
779 if (ownerEnabled
) flags
|= DF_OWNERENABLED
;
784 hwnd
= User32CreateWindowEx(template.exStyle
, (LPCSTR
)template.className
, (LPCSTR
)template.caption
,
785 template.style
& ~WS_VISIBLE
,
786 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
787 owner
, hMenu
, hInst
, NULL
,
792 LPSTR
class = (LPSTR
)template.className
;
793 LPSTR caption
= (LPSTR
)template.caption
;
797 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, template.className
, -1, NULL
, 0, NULL
, NULL
);
798 class = HeapAlloc( GetProcessHeap(), 0, len
);
800 WideCharToMultiByte( CP_ACP
, 0, template.className
, -1, class, len
, NULL
, NULL
);
804 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, template.caption
, -1, NULL
, 0, NULL
, NULL
);
805 caption
= HeapAlloc( GetProcessHeap(), 0, len
);
807 WideCharToMultiByte( CP_ACP
, 0, template.caption
, -1, caption
, len
, NULL
, NULL
);
810 if (class != NULL
&& caption
!= NULL
)
812 hwnd
= User32CreateWindowEx(template.exStyle
, class, caption
,
813 template.style
& ~WS_VISIBLE
,
814 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
815 owner
, hMenu
, hInst
, NULL
,
820 if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
821 if (HIWORD(caption
)) HeapFree( GetProcessHeap(), 0, caption
);
826 if (hUserFont
) DeleteObject( hUserFont
);
827 if (hMenu
) NtUserDestroyMenu( hMenu
);
828 if (modal
&& (flags
& DF_OWNERENABLED
)) DIALOG_EnableOwner(owner
);
832 /* moved this from the top of the method to here as DIALOGINFO structure
833 will be valid only after WM_CREATE message has been handled in DefDlgProc
834 All the members of the structure get filled here using temp variables */
836 dlgInfo
= DIALOG_get_info( hwnd
, TRUE
);
839 if (hUserFont
) DeleteObject( hUserFont
);
840 if (hMenu
) NtUserDestroyMenu( hMenu
);
841 if (modal
&& (flags
& DF_OWNERENABLED
)) DIALOG_EnableOwner(owner
);
845 // dlgInfo->hwndFocus = 0;
846 dlgInfo
->hUserFont
= hUserFont
;
847 dlgInfo
->hMenu
= hMenu
;
848 dlgInfo
->xBaseUnit
= xBaseUnit
;
849 dlgInfo
->yBaseUnit
= yBaseUnit
;
850 // dlgInfo->idResult = 0;
851 dlgInfo
->flags
= flags
;
852 // dlgInfo->hDialogHeap = 0;
854 if (template.helpId
) SetWindowContextHelpId( hwnd
, template.helpId
);
856 if (unicode
) SetWindowLongPtrW( hwnd
, DWLP_DLGPROC
, (ULONG_PTR
)dlgProc
);
857 else SetWindowLongPtrA( hwnd
, DWLP_DLGPROC
, (ULONG_PTR
)dlgProc
);
859 if (dlgProc
&& dlgInfo
->hUserFont
)
860 SendMessageW( hwnd
, WM_SETFONT
, (WPARAM
)dlgInfo
->hUserFont
, 0 );
862 /* Create controls */
864 if (DIALOG_CreateControls32( hwnd
, dlgTemplate
, &template, hInst
, unicode
))
866 /* Send initialisation messages and set focus */
869 if (SendMessageW( hwnd
, WM_INITDIALOG
, (WPARAM
)dlgInfo
->hwndFocus
, param
) &&
870 ((~template.style
& DS_CONTROL
) || (template.style
& WS_VISIBLE
)))
872 /* By returning TRUE, app has requested a default focus assignment */
873 dlgInfo
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
874 if( dlgInfo
->hwndFocus
)
875 NtUserSetFocus( dlgInfo
->hwndFocus
);
878 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
))
879 SendMessageW( hwnd
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_INITIALIZE
, 0), 0);
881 if (template.style
& WS_VISIBLE
&& !(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_VISIBLE
))
883 NtUserShowWindow( hwnd
, SW_SHOWNORMAL
); /* SW_SHOW doesn't always work */
887 if (modal
&& ownerEnabled
) DIALOG_EnableOwner(owner
);
888 if( IsWindow(hwnd
) ) NtUserDestroyWindow( hwnd
);
892 /***********************************************************************
895 * Set the focus to a control of the dialog, selecting the text if
896 * the control is an edit dialog.
898 static void DEFDLG_SetFocus( HWND hwndDlg
, HWND hwndCtrl
)
900 HWND hwndPrev
= GetFocus();
902 if (IsChild( hwndDlg
, hwndPrev
))
904 if (SendMessageW( hwndPrev
, WM_GETDLGCODE
, 0, 0 ) & DLGC_HASSETSEL
)
905 SendMessageW( hwndPrev
, EM_SETSEL
, -1, 0 );
907 if (SendMessageW( hwndCtrl
, WM_GETDLGCODE
, 0, 0 ) & DLGC_HASSETSEL
)
908 SendMessageW( hwndCtrl
, EM_SETSEL
, 0, -1 );
909 NtUserSetFocus( hwndCtrl
);
912 /***********************************************************************
915 static void DEFDLG_SaveFocus( HWND hwnd
)
918 HWND hwndFocus
= GetFocus();
920 if (!hwndFocus
|| !IsChild( hwnd
, hwndFocus
)) return;
921 if (!(infoPtr
= GETDLGINFO(hwnd
))) return;
922 infoPtr
->hwndFocus
= hwndFocus
;
923 /* Remove default button */
926 /***********************************************************************
927 * DEFDLG_RestoreFocus
929 static void DEFDLG_RestoreFocus( HWND hwnd
)
933 if (IsIconic( hwnd
)) return;
934 if (!(infoPtr
= GETDLGINFO(hwnd
))) return;
935 /* Don't set the focus back to controls if EndDialog is already called.*/
936 if (infoPtr
->flags
& DF_END
) return;
937 if (!IsWindow(infoPtr
->hwndFocus
) || infoPtr
->hwndFocus
== hwnd
) {
938 /* If no saved focus control exists, set focus to the first visible,
939 non-disabled, WS_TABSTOP control in the dialog */
940 infoPtr
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
941 if (!IsWindow( infoPtr
->hwndFocus
)) return;
943 NtUserSetFocus( infoPtr
->hwndFocus
);
945 /* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
946 sometimes losing focus when receiving WM_SETFOCUS messages. */
949 /***********************************************************************
950 * DEFDLG_FindDefButton
952 * Find the current default push-button.
954 static HWND
DEFDLG_FindDefButton( HWND hwndDlg
)
956 HWND hwndChild
, hwndTmp
;
958 hwndChild
= GetWindow( hwndDlg
, GW_CHILD
);
961 if (SendMessageW( hwndChild
, WM_GETDLGCODE
, 0, 0 ) & DLGC_DEFPUSHBUTTON
)
964 /* Recurse into WS_EX_CONTROLPARENT controls */
965 if (GetWindowLongW( hwndChild
, GWL_EXSTYLE
) & WS_EX_CONTROLPARENT
)
967 LONG dsStyle
= GetWindowLongW( hwndChild
, GWL_STYLE
);
968 if ((dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
) &&
969 (hwndTmp
= DEFDLG_FindDefButton(hwndChild
)) != NULL
)
972 hwndChild
= GetWindow( hwndChild
, GW_HWNDNEXT
);
977 /***********************************************************************
980 * Set the default button id.
982 static BOOL
DEFDLG_SetDefId( HWND hwndDlg
, DIALOGINFO
*dlgInfo
, WPARAM wParam
)
984 DWORD dlgcode
=0; /* initialize just to avoid a warning */
985 HWND hwndOld
, hwndNew
= GetDlgItem(hwndDlg
, wParam
);
986 INT old_id
= dlgInfo
->idResult
;
988 dlgInfo
->idResult
= wParam
;
990 !((dlgcode
=SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 ))
991 & (DLGC_UNDEFPUSHBUTTON
| DLGC_BUTTON
)))
992 return FALSE
; /* Destination is not a push button */
994 /* Make sure the old default control is a valid push button ID */
995 hwndOld
= GetDlgItem( hwndDlg
, old_id
);
996 if (!hwndOld
|| !(SendMessageW( hwndOld
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
997 hwndOld
= DEFDLG_FindDefButton( hwndDlg
);
998 if (hwndOld
&& hwndOld
!= hwndNew
)
999 SendMessageW( hwndOld
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
1003 if(dlgcode
& DLGC_UNDEFPUSHBUTTON
)
1004 SendMessageW( hwndNew
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
1009 /***********************************************************************
1010 * DEFDLG_SetDefButton
1012 * Set the new default button to be hwndNew.
1014 static BOOL
DEFDLG_SetDefButton( HWND hwndDlg
, DIALOGINFO
*dlgInfo
, HWND hwndNew
)
1016 DWORD dlgcode
=0; /* initialize just to avoid a warning */
1017 HWND hwndOld
= GetDlgItem( hwndDlg
, dlgInfo
->idResult
);
1020 !((dlgcode
=SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 ))
1021 & (DLGC_UNDEFPUSHBUTTON
| DLGC_DEFPUSHBUTTON
)))
1024 * Need to draw only default push button rectangle.
1025 * Since the next control is not a push button, need to draw the push
1026 * button rectangle for the default control.
1029 dlgcode
= SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 );
1032 /* Make sure the old default control is a valid push button ID */
1033 if (!hwndOld
|| !(SendMessageW( hwndOld
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
1034 hwndOld
= DEFDLG_FindDefButton( hwndDlg
);
1035 if (hwndOld
&& hwndOld
!= hwndNew
)
1036 SendMessageW( hwndOld
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
1040 if(dlgcode
& DLGC_UNDEFPUSHBUTTON
)
1041 SendMessageW( hwndNew
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
1046 /***********************************************************************
1049 * Implementation of DefDlgProc(). Only handle messages that need special
1050 * handling for dialogs.
1052 static LRESULT
DEFDLG_Proc( HWND hwnd
, UINT msg
, WPARAM wParam
,
1053 LPARAM lParam
, DIALOGINFO
*dlgInfo
)
1059 HBRUSH brush
= (HBRUSH
)SendMessageW( hwnd
, WM_CTLCOLORDLG
, wParam
, (LPARAM
)hwnd
);
1060 if (!brush
) brush
= (HBRUSH
)DefWindowProcW( hwnd
, WM_CTLCOLORDLG
, wParam
, (LPARAM
)hwnd
);
1064 HDC hdc
= (HDC
)wParam
;
1065 GetClientRect( hwnd
, &rect
);
1066 DPtoLP( hdc
, (LPPOINT
)&rect
, 2 );
1067 FillRect( hdc
, &rect
, brush
);
1072 if ((dlgInfo
= (DIALOGINFO
*)SetWindowLongPtrW( hwnd
, DWLP_ROS_DIALOGINFO
, 0 )))
1074 /* Free dialog heap (if created) */
1075 /*if (dlgInfo->hDialogHeap)
1077 GlobalUnlock16(dlgInfo->hDialogHeap);
1078 GlobalFree16(dlgInfo->hDialogHeap);
1080 if (dlgInfo
->hUserFont
) DeleteObject( dlgInfo
->hUserFont
);
1081 if (dlgInfo
->hMenu
) NtUserDestroyMenu( dlgInfo
->hMenu
);
1082 HeapFree( GetProcessHeap(), 0, dlgInfo
);
1084 /* Window clean-up */
1085 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1088 if (!wParam
) DEFDLG_SaveFocus( hwnd
);
1089 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1092 if (wParam
) DEFDLG_RestoreFocus( hwnd
);
1093 else DEFDLG_SaveFocus( hwnd
);
1097 DEFDLG_RestoreFocus( hwnd
);
1101 if (dlgInfo
&& !(dlgInfo
->flags
& DF_END
))
1102 DEFDLG_SetDefId( hwnd
, dlgInfo
, wParam
);
1106 if (dlgInfo
&& !(dlgInfo
->flags
& DF_END
))
1109 if (dlgInfo
->idResult
)
1110 return MAKELONG( dlgInfo
->idResult
, DC_HASDEFID
);
1111 if ((hwndDefId
= DEFDLG_FindDefButton( hwnd
)))
1112 return MAKELONG( GetDlgCtrlID( hwndDefId
), DC_HASDEFID
);
1119 HWND hwndDest
= (HWND
)wParam
;
1121 hwndDest
= GetNextDlgTabItem(hwnd
, GetFocus(), wParam
);
1122 if (hwndDest
) DEFDLG_SetFocus( hwnd
, hwndDest
);
1123 DEFDLG_SetDefButton( hwnd
, dlgInfo
, hwndDest
);
1127 case WM_ENTERMENULOOP
:
1128 case WM_LBUTTONDOWN
:
1129 case WM_NCLBUTTONDOWN
:
1131 HWND hwndFocus
= GetFocus();
1134 /* always make combo box hide its listbox control */
1135 if (!SendMessageW( hwndFocus
, CB_SHOWDROPDOWN
, FALSE
, 0 ))
1136 SendMessageW( GetParent(hwndFocus
), CB_SHOWDROPDOWN
, FALSE
, 0 );
1139 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1142 return dlgInfo
? (LRESULT
)dlgInfo
->hUserFont
: 0;
1145 PostMessageA( hwnd
, WM_COMMAND
, MAKEWPARAM(IDCANCEL
, BN_CLICKED
),
1146 (LPARAM
)GetDlgItem( hwnd
, IDCANCEL
) );
1152 /***********************************************************************
1155 static LRESULT
DEFDLG_Epilog(HWND hwnd
, UINT msg
, BOOL fResult
)
1158 // TODO: where's wine's WM_CTLCOLOR from?
1159 if ((msg
>= WM_CTLCOLORMSGBOX
&& msg
<= WM_CTLCOLORSTATIC
) ||
1160 msg
== WM_CTLCOLOR
|| msg
== WM_COMPAREITEM
||
1161 msg
== WM_VKEYTOITEM
|| msg
== WM_CHARTOITEM
||
1162 msg
== WM_QUERYDRAGICON
|| msg
== WM_INITDIALOG
)
1165 return GetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
);
1168 /***********************************************************************
1169 * DIALOG_GetNextTabItem
1171 * Helper for GetNextDlgTabItem
1173 static HWND
DIALOG_GetNextTabItem( HWND hwndMain
, HWND hwndDlg
, HWND hwndCtrl
, BOOL fPrevious
)
1177 UINT wndSearch
= fPrevious
? GW_HWNDPREV
: GW_HWNDNEXT
;
1179 HWND hChildFirst
= 0;
1183 hChildFirst
= GetWindow(hwndDlg
,GW_CHILD
);
1184 if(fPrevious
) hChildFirst
= GetWindow(hChildFirst
,GW_HWNDLAST
);
1186 else if (IsChild( hwndMain
, hwndCtrl
))
1188 hChildFirst
= GetWindow(hwndCtrl
,wndSearch
);
1191 if(GetParent(hwndCtrl
) != hwndMain
)
1192 /* i.e. if we are not at the top level of the recursion */
1193 hChildFirst
= GetWindow(GetParent(hwndCtrl
),wndSearch
);
1195 hChildFirst
= GetWindow(hwndCtrl
, fPrevious
? GW_HWNDLAST
: GW_HWNDFIRST
);
1201 dsStyle
= GetWindowLongA(hChildFirst
,GWL_STYLE
);
1202 exStyle
= GetWindowLongA(hChildFirst
,GWL_EXSTYLE
);
1203 if( (exStyle
& WS_EX_CONTROLPARENT
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
1206 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hChildFirst
,NULL
,fPrevious
);
1207 if (retWnd
) return (retWnd
);
1209 else if( (dsStyle
& WS_TABSTOP
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
1211 return (hChildFirst
);
1213 hChildFirst
= GetWindow(hChildFirst
,wndSearch
);
1217 HWND hParent
= GetParent(hwndCtrl
);
1220 if(hParent
== hwndMain
) break;
1221 retWnd
= DIALOG_GetNextTabItem(hwndMain
,GetParent(hParent
),hParent
,fPrevious
);
1223 hParent
= GetParent(hParent
);
1226 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hwndMain
,NULL
,fPrevious
);
1228 return retWnd
? retWnd
: hwndCtrl
;
1232 /**********************************************************************
1233 * DIALOG_DlgDirListW
1235 * Helper function for DlgDirList*W
1237 static INT
DIALOG_DlgDirListW( HWND hDlg
, LPWSTR spec
, INT idLBox
,
1238 INT idStatic
, UINT attrib
, BOOL combo
)
1241 LPWSTR orig_spec
= spec
;
1242 WCHAR any
[] = {'*','.','*',0};
1244 #define SENDMSG(msg,wparam,lparam) \
1245 ((attrib & DDL_POSTMSGS) ? PostMessageW( hwnd, msg, wparam, lparam ) \
1246 : SendMessageW( hwnd, msg, wparam, lparam ))
1248 // TRACE("%p '%s' %d %d %04x\n",
1249 // hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
1251 /* If the path exists and is a directory, chdir to it */
1252 if (!spec
|| !spec
[0] || SetCurrentDirectoryW( spec
)) spec
= any
;
1257 if ((p2
= strchrW( p
, ':' ))) p
= p2
+ 1;
1258 if ((p2
= strrchrW( p
, '\\' ))) p
= p2
;
1259 if ((p2
= strrchrW( p
, '/' ))) p
= p2
;
1264 if (!SetCurrentDirectoryW( spec
))
1266 *p
= sep
; /* Restore the original spec */
1273 TRACE( "mask=%s\n", spec
);
1275 if (idLBox
&& ((hwnd
= GetDlgItem( hDlg
, idLBox
)) != 0))
1277 if (attrib
== DDL_DRIVES
) attrib
|= DDL_EXCLUSIVE
;
1279 SENDMSG( combo
? CB_RESETCONTENT
: LB_RESETCONTENT
, 0, 0 );
1280 if (attrib
& DDL_DIRECTORY
)
1282 if (!(attrib
& DDL_EXCLUSIVE
))
1284 SENDMSG( combo
? CB_DIR
: LB_DIR
,
1285 attrib
& ~(DDL_DIRECTORY
| DDL_DRIVES
),
1288 SENDMSG( combo
? CB_DIR
: LB_DIR
,
1289 (attrib
& (DDL_DIRECTORY
| DDL_DRIVES
)) | DDL_EXCLUSIVE
,
1294 SENDMSG( combo
? CB_DIR
: LB_DIR
, attrib
, (LPARAM
)spec
);
1298 /* Convert path specification to uppercase */
1299 if (spec
) CharUpperW(spec
);
1301 if (idStatic
&& ((hwnd
= GetDlgItem( hDlg
, idStatic
)) != 0))
1303 WCHAR temp
[MAX_PATH
];
1304 GetCurrentDirectoryW( sizeof(temp
)/sizeof(WCHAR
), temp
);
1306 /* Can't use PostMessage() here, because the string is on the stack */
1307 SetDlgItemTextW( hDlg
, idStatic
, temp
);
1310 if (orig_spec
&& (spec
!= orig_spec
))
1312 /* Update the original file spec */
1314 while ((*orig_spec
++ = *p
++));
1321 /**********************************************************************
1322 * DIALOG_DlgDirListA
1324 * Helper function for DlgDirList*A
1326 static INT
DIALOG_DlgDirListA( HWND hDlg
, LPSTR spec
, INT idLBox
,
1327 INT idStatic
, UINT attrib
, BOOL combo
)
1331 INT ret
, len
= MultiByteToWideChar( CP_ACP
, 0, spec
, -1, NULL
, 0 );
1332 LPWSTR specW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
1335 MultiByteToWideChar( CP_ACP
, 0, spec
, -1, specW
, len
);
1336 ret
= DIALOG_DlgDirListW( hDlg
, specW
, idLBox
, idStatic
, attrib
, combo
);
1337 WideCharToMultiByte( CP_ACP
, 0, specW
, -1, spec
, 0x7fffffff, NULL
, NULL
);
1338 HeapFree( GetProcessHeap(), 0, specW
);
1341 return DIALOG_DlgDirListW( hDlg
, NULL
, idLBox
, idStatic
, attrib
, combo
);
1344 /**********************************************************************
1345 * DIALOG_DlgDirSelect
1347 * Helper function for DlgDirSelect*
1349 static BOOL
DIALOG_DlgDirSelect( HWND hwnd
, LPWSTR str
, INT len
,
1350 INT id
, BOOL unicode
, BOOL combo
)
1352 WCHAR
*buffer
, *ptr
;
1355 HWND listbox
= GetDlgItem( hwnd
, id
);
1357 TRACE("%p '%s' %d\n", hwnd
, str
, id
);
1358 if (!listbox
) return FALSE
;
1360 item
= SendMessageW(listbox
, combo
? CB_GETCURSEL
: LB_GETCURSEL
, 0, 0 );
1361 if (item
== LB_ERR
) return FALSE
;
1362 size
= SendMessageW(listbox
, combo
? CB_GETLBTEXTLEN
: LB_GETTEXTLEN
, 0, 0 );
1363 if (size
== LB_ERR
) return FALSE
;
1365 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, (size
+2) * sizeof(WCHAR
) ))) return FALSE
;
1367 SendMessageW( listbox
, combo
? CB_GETLBTEXT
: LB_GETTEXT
, item
, (LPARAM
)buffer
);
1369 if ((ret
= (buffer
[0] == '['))) /* drive or directory */
1371 if (buffer
[1] == '-') /* drive */
1379 buffer
[strlenW(buffer
)-1] = '\\';
1385 /* Filenames without a dot extension must have one tacked at the end */
1386 if (strchrW(buffer
, '.') == NULL
)
1388 buffer
[strlenW(buffer
)+1] = '\0';
1389 buffer
[strlenW(buffer
)] = '.';
1396 if (len
> 0 && !WideCharToMultiByte( CP_ACP
, 0, ptr
, -1, (LPSTR
)str
, len
, 0, 0 ))
1397 ((LPSTR
)str
)[len
-1] = 0;
1400 lstrcpynW( str
, ptr
, len
);
1402 HeapFree( GetProcessHeap(), 0, buffer
);
1403 TRACE("Returning %d '%s'\n", ret
, str
);
1407 /***********************************************************************
1408 * GetDlgItemEnumProc
1410 * Callback for GetDlgItem
1412 BOOL CALLBACK
GetDlgItemEnumProc (HWND hwnd
, LPARAM lParam
)
1414 GETDLGITEMINFO
* info
= (GETDLGITEMINFO
*)lParam
;
1415 if(info
->nIDDlgItem
== GetWindowLongW( hwnd
, GWL_ID
))
1417 info
->control
= hwnd
;
1424 /* FUNCTIONS *****************************************************************/
1431 CreateDialogIndirectParamAorW(
1432 HINSTANCE hInstance
,
1433 LPCDLGTEMPLATE lpTemplate
,
1435 DLGPROC lpDialogFunc
,
1440 * This function might be obsolete since I don't think it is exported by NT
1441 * Also wine has one more parameter identifying weather it should call
1442 * the function with unicode or not
1444 return DIALOG_CreateIndirect( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, !Flags
, FALSE
);
1453 CreateDialogIndirectParamA(
1454 HINSTANCE hInstance
,
1455 LPCDLGTEMPLATE lpTemplate
,
1457 DLGPROC lpDialogFunc
,
1460 return CreateDialogIndirectParamAorW( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, 2 );
1469 CreateDialogIndirectParamW(
1470 HINSTANCE hInstance
,
1471 LPCDLGTEMPLATE lpTemplate
,
1473 DLGPROC lpDialogFunc
,
1476 return CreateDialogIndirectParamAorW( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, 0);
1486 HINSTANCE hInstance
,
1487 LPCSTR lpTemplateName
,
1489 DLGPROC lpDialogFunc
,
1495 if (!(hrsrc
= FindResourceA( hInstance
, lpTemplateName
, (LPCSTR
)RT_DIALOG
))) return 0;
1496 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1497 return CreateDialogIndirectParamA( hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
);
1507 HINSTANCE hInstance
,
1508 LPCWSTR lpTemplateName
,
1510 DLGPROC lpDialogFunc
,
1516 if (!(hrsrc
= FindResourceW( hInstance
, lpTemplateName
, (LPCWSTR
)RT_DIALOG
))) return 0;
1517 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1518 return CreateDialogIndirectParamW( hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
);
1534 BOOL result
= FALSE
;
1535 DIALOGINFO
* dlgInfo
;
1537 /* if there's no dialog info property then call default windows proc?? */
1538 if (!(dlgInfo
= DIALOG_get_info(hDlg
, TRUE
)))
1539 return DefWindowProcA( hDlg
, Msg
, wParam
, lParam
);
1541 SetWindowLongPtrW( hDlg
, DWLP_MSGRESULT
, 0 );
1543 if ((dlgproc
= (WNDPROC
)GetWindowLongPtrW( hDlg
, DWLP_DLGPROC
)))
1545 /* Call dialog procedure */
1546 result
= CallWindowProcA( dlgproc
, hDlg
, Msg
, wParam
, lParam
);
1549 if (!result
&& IsWindow(hDlg
))
1551 /* callback didn't process this message */
1565 case WM_ENTERMENULOOP
:
1566 case WM_LBUTTONDOWN
:
1567 case WM_NCLBUTTONDOWN
:
1568 return DEFDLG_Proc( hDlg
, Msg
, wParam
, lParam
, dlgInfo
);
1571 case WM_COMPAREITEM
:
1576 return DefWindowProcA( hDlg
, Msg
, wParam
, lParam
);
1579 return DEFDLG_Epilog(hDlg
, Msg
, result
);
1595 BOOL result
= FALSE
;
1596 DIALOGINFO
* dlgInfo
;
1598 /* if there's no dialog info property then call default windows proc?? */
1599 if (!(dlgInfo
= DIALOG_get_info(hDlg
, TRUE
)))
1600 return DefWindowProcW( hDlg
, Msg
, wParam
, lParam
);
1602 SetWindowLongPtrW( hDlg
, DWLP_MSGRESULT
, 0 );
1604 if ((dlgproc
= (WNDPROC
)GetWindowLongPtrW( hDlg
, DWLP_DLGPROC
)))
1606 /* Call dialog procedure */
1607 result
= CallWindowProcW( dlgproc
, hDlg
, Msg
, wParam
, lParam
);
1610 if (!result
&& IsWindow(hDlg
))
1612 /* callback didn't process this message */
1626 case WM_ENTERMENULOOP
:
1627 case WM_LBUTTONDOWN
:
1628 case WM_NCLBUTTONDOWN
:
1629 return DEFDLG_Proc( hDlg
, Msg
, wParam
, lParam
, dlgInfo
);
1632 case WM_COMPAREITEM
:
1637 return DefWindowProcW( hDlg
, Msg
, wParam
, lParam
);
1640 return DEFDLG_Epilog(hDlg
, Msg
, result
);
1649 DialogBoxIndirectParamAorW(
1650 HINSTANCE hInstance
,
1651 LPCDLGTEMPLATE hDialogTemplate
,
1653 DLGPROC lpDialogFunc
,
1658 * This function might be obsolete since I don't think it is exported by NT
1659 * Also wine has one more parameter identifying weather it should call
1660 * the function with unicode or not
1662 HWND hWnd
= DIALOG_CreateIndirect( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, !Flags
, TRUE
);
1663 if (hWnd
) return DIALOG_DoDialogBox( hWnd
, hWndParent
);
1673 DialogBoxIndirectParamA(
1674 HINSTANCE hInstance
,
1675 LPCDLGTEMPLATE hDialogTemplate
,
1677 DLGPROC lpDialogFunc
,
1680 return DialogBoxIndirectParamAorW( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, 2);
1689 DialogBoxIndirectParamW(
1690 HINSTANCE hInstance
,
1691 LPCDLGTEMPLATE hDialogTemplate
,
1693 DLGPROC lpDialogFunc
,
1696 return DialogBoxIndirectParamAorW( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, 0);
1706 HINSTANCE hInstance
,
1707 LPCSTR lpTemplateName
,
1709 DLGPROC lpDialogFunc
,
1716 if (!(hrsrc
= FindResourceA( hInstance
, lpTemplateName
, (LPCSTR
)RT_DIALOG
)) ||
1717 !(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
)))
1719 SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND
);
1722 if (hWndParent
!= NULL
&& !IsWindow(hWndParent
))
1724 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
1727 hwnd
= DIALOG_CreateIndirect(hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
, FALSE
, TRUE
);
1728 if (hwnd
) return DIALOG_DoDialogBox(hwnd
, hWndParent
);
1739 HINSTANCE hInstance
,
1740 LPCWSTR lpTemplateName
,
1742 DLGPROC lpDialogFunc
,
1749 if (!(hrsrc
= FindResourceW( hInstance
, lpTemplateName
, (LPCWSTR
)RT_DIALOG
)) ||
1750 !(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
)))
1752 SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND
);
1755 if (hWndParent
!= NULL
&& !IsWindow(hWndParent
))
1757 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
1760 hwnd
= DIALOG_CreateIndirect(hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
, TRUE
, TRUE
);
1761 if (hwnd
) return DIALOG_DoDialogBox(hwnd
, hWndParent
);
1778 return DIALOG_DlgDirListA( hDlg
, lpPathSpec
, nIDListBox
, nIDStaticPath
, uFileType
, FALSE
);
1787 DlgDirListComboBoxA(
1794 return DIALOG_DlgDirListA( hDlg
, lpPathSpec
, nIDComboBox
, nIDStaticPath
, uFiletype
, TRUE
);
1803 DlgDirListComboBoxW(
1810 return DIALOG_DlgDirListW( hDlg
, lpPathSpec
, nIDComboBox
, nIDStaticPath
, uFiletype
, TRUE
);
1826 return DIALOG_DlgDirListW( hDlg
, lpPathSpec
, nIDListBox
, nIDStaticPath
, uFileType
, FALSE
);
1835 DlgDirSelectComboBoxExA(
1841 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDComboBox
, FALSE
, TRUE
);
1850 DlgDirSelectComboBoxExW(
1856 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDComboBox
, TRUE
, TRUE
);
1871 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDListBox
, FALSE
, FALSE
);
1886 return DIALOG_DlgDirSelect( hDlg
, lpString
, nCount
, nIDListBox
, TRUE
, FALSE
);
1899 BOOL wasEnabled
= TRUE
;
1900 DIALOGINFO
* dlgInfo
;
1903 if (!(dlgInfo
= GETDLGINFO(hDlg
))) return FALSE
;
1905 dlgInfo
->idResult
= nResult
;
1906 dlgInfo
->flags
|= DF_END
;
1907 wasEnabled
= (dlgInfo
->flags
& DF_OWNERENABLED
);
1909 if (wasEnabled
&& (owner
= GetWindow( hDlg
, GW_OWNER
)))
1910 DIALOG_EnableOwner( owner
);
1912 /* Windows sets the focus to the dialog itself in EndDialog */
1914 if (IsChild(hDlg
, GetFocus()))
1915 NtUserSetFocus( hDlg
);
1917 /* Don't have to send a ShowWindow(SW_HIDE), just do
1918 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1920 NtUserSetWindowPos(hDlg
, NULL
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
1921 | SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_HIDEWINDOW
);
1923 if (hDlg
== GetActiveWindow()) WinPosActivateOtherWindow( hDlg
);
1925 /* unblock dialog loop */
1926 PostMessageA(hDlg
, WM_NULL
, 0, 0);
1936 GetDialogBaseUnits(VOID
)
1945 if ((hdc
= NtUserGetDC(0)))
1947 size
.cx
= GdiGetCharDimensions( hdc
, NULL
, &size
.cy
);
1948 if (size
.cx
) units
= MAKELONG( size
.cx
, size
.cy
);
1949 ReleaseDC( 0, hdc
);
1964 return GetWindowLongPtrW( hwndCtl
, GWLP_ID
);
1977 GETDLGITEMINFO info
;
1978 info
.nIDDlgItem
= nIDDlgItem
;
1980 if(hDlg
&& !EnumChildWindows(hDlg
, (WNDENUMPROC
)&GetDlgItemEnumProc
, (LPARAM
)&info
))
1981 return info
.control
;
2002 if (lpTranslated
) *lpTranslated
= FALSE
;
2003 if (!SendDlgItemMessageA(hDlg
, nIDDlgItem
, WM_GETTEXT
, sizeof(str
), (LPARAM
)str
))
2007 result
= strtol( str
, &endptr
, 10 );
2008 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
2011 if (((result
== 0) || (result
== 0xFFFFFFFF))/* && (errno == ERANGE) */)
2016 result
= strtoul( str
, &endptr
, 10 );
2017 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
2020 if ((result
== 0xFFFFFFFF)/* && (errno == ERANGE) */) return 0;
2022 if (lpTranslated
) *lpTranslated
= TRUE
;
2023 return (UINT
)result
;
2038 if (lpString
&& (nMaxCount
> 0)) lpString
[0] = '\0';
2039 return (UINT
)SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
2054 if (lpString
&& (nMaxCount
> 0)) lpString
[0] = '\0';
2055 return (UINT
)SendDlgItemMessageW( hDlg
, nIDDlgItem
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
2063 GetNextDlgGroupItem(
2068 HWND hwnd
, hwndNext
, retvalue
, hwndLastGroup
= 0;
2070 BOOL fSkipping
=FALSE
;
2072 if (hDlg
== hCtl
) hCtl
= NULL
;
2073 if (!hCtl
&& bPrevious
) return 0;
2075 /* if the hwndCtrl is the child of the control in the hwndDlg,
2076 * then the hwndDlg has to be the parent of the hwndCtrl */
2080 if (!IsChild (hDlg
, hCtl
)) return 0;
2081 /* Make sure hwndCtrl is a top-level child */
2086 /* No ctrl specified -> start from the beginning */
2087 if (!(hCtl
= GetWindow( hDlg
, GW_CHILD
))) return 0;
2088 /* MSDN is wrong. fPrevious does not result in the last child */
2090 /* No ctrl specified -> start from the beginning */
2091 if (!(hCtl
= GetWindow( hDlg
, GW_CHILD
))) return 0;
2093 /* MSDN is wrong. fPrevious does not result in the last child */
2095 /* Maybe that first one is valid. If so then we don't want to skip it*/
2096 if ((GetWindowLongW( hCtl
, GWL_STYLE
) & (WS_VISIBLE
|WS_DISABLED
)) == WS_VISIBLE
)
2103 /* Always go forward around the group and list of controls; for the
2104 * previous control keep track; for the next break when you find one
2108 while (hwndNext
= GetWindow (hwnd
, GW_HWNDNEXT
),
2113 /* Climb out until there is a next sibling of the ancestor or we
2114 * reach the top (in which case we loop back to the start)
2116 if (hDlg
== GetParent (hwnd
))
2118 /* Wrap around to the beginning of the list, within the same
2119 * group. (Once only)
2121 if (fLooped
) goto end
;
2123 hwndNext
= GetWindow (hDlg
, GW_CHILD
);
2127 hwnd
= GetParent (hwnd
);
2128 hwndNext
= GetWindow (hwnd
, GW_HWNDNEXT
);
2133 /* Wander down the leading edge of controlparents */
2134 while ( (GetWindowLongW (hwnd
, GWL_EXSTYLE
) & WS_EX_CONTROLPARENT
) &&
2135 ((GetWindowLongW (hwnd
, GWL_STYLE
) & (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
) &&
2136 (hwndNext
= GetWindow (hwnd
, GW_CHILD
)))
2138 /* Question. If the control is a control parent but either has no
2139 * children or is not visible/enabled then if it has a WS_GROUP does
2140 * it count? For that matter does it count anyway?
2141 * I believe it doesn't count.
2144 if ((GetWindowLongW (hwnd
, GWL_STYLE
) & WS_GROUP
))
2146 hwndLastGroup
= hwnd
;
2149 /* Look for the beginning of the group */
2156 if (!fSkipping
) break;
2157 if (hwndLastGroup
== hwnd
) break;
2158 hwnd
= hwndLastGroup
;
2164 (GetWindowLongW (hwnd
, GWL_STYLE
) & (WS_VISIBLE
|WS_DISABLED
)) ==
2168 if (!bPrevious
) break;
2186 /* Undocumented but tested under Win2000 and WinME */
2187 if (hDlg
== hCtl
) hCtl
= NULL
;
2189 /* Contrary to MSDN documentation, tested under Win2000 and WinME
2190 * NB GetLastError returns whatever was set before the function was
2193 if (!hCtl
&& bPrevious
) return 0;
2195 return DIALOG_GetNextTabItem(hDlg
, hDlg
, hCtl
, bPrevious
);
2206 return IsDialogMessageW(hDlg
, lpMsg
);
2210 /***********************************************************************
2211 * DIALOG_FixOneChildOnChangeFocus
2213 * Callback helper for DIALOG_FixChildrenOnChangeFocus
2216 static BOOL CALLBACK
DIALOG_FixOneChildOnChangeFocus (HWND hwndChild
,
2219 /* If a default pushbutton then no longer default */
2220 if (DLGC_DEFPUSHBUTTON
& SendMessageW (hwndChild
, WM_GETDLGCODE
, 0, 0))
2221 SendMessageW (hwndChild
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
2225 /***********************************************************************
2226 * DIALOG_FixChildrenOnChangeFocus
2228 * Following the change of focus that occurs for example after handling
2229 * a WM_KEYDOWN VK_TAB in IsDialogMessage, some tidying of the dialog's
2230 * children may be required.
2232 static void DIALOG_FixChildrenOnChangeFocus (HWND hwndDlg
, HWND hwndNext
)
2234 INT dlgcode_next
= SendMessageW (hwndNext
, WM_GETDLGCODE
, 0, 0);
2235 /* INT dlgcode_dlg = SendMessageW (hwndDlg, WM_GETDLGCODE, 0, 0); */
2236 /* Windows does ask for this. I don't know why yet */
2238 EnumChildWindows (hwndDlg
, DIALOG_FixOneChildOnChangeFocus
, 0);
2240 /* If the button that is getting the focus WAS flagged as the default
2241 * pushbutton then ask the dialog what it thinks the default is and
2242 * set that in the default style.
2244 if (dlgcode_next
& DLGC_DEFPUSHBUTTON
)
2246 DWORD def_id
= SendMessageW (hwndDlg
, DM_GETDEFID
, 0, 0);
2247 if (HIWORD(def_id
) == DC_HASDEFID
)
2250 def_id
= LOWORD(def_id
);
2251 hwndDef
= GetDlgItem (hwndDlg
, def_id
);
2254 INT dlgcode_def
= SendMessageW (hwndDef
, WM_GETDLGCODE
, 0, 0);
2255 /* I know that if it is a button then it should already be a
2256 * UNDEFPUSHBUTTON, since we have just told the buttons to
2257 * change style. But maybe they ignored our request
2259 if ((dlgcode_def
& DLGC_BUTTON
) &&
2260 (dlgcode_def
& DLGC_UNDEFPUSHBUTTON
))
2262 SendMessageW (hwndDef
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
2267 else if ((dlgcode_next
& DLGC_BUTTON
) && (dlgcode_next
& DLGC_UNDEFPUSHBUTTON
))
2269 SendMessageW (hwndNext
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
2270 /* I wonder why it doesn't send a DM_SETDEFID */
2286 if (CallMsgFilterW( lpMsg
, MSGF_DIALOGBOX
)) return TRUE
;
2288 if ((hDlg
!= lpMsg
->hwnd
) && !IsChild( hDlg
, lpMsg
->hwnd
)) return FALSE
;
2290 if (hDlg
== GetDesktopWindow()) return FALSE
;
2292 hDlg
= DIALOG_FindMsgDestination(hDlg
);
2294 switch(lpMsg
->message
)
2297 dlgCode
= SendMessageW( lpMsg
->hwnd
, WM_GETDLGCODE
, lpMsg
->wParam
, (LPARAM
)lpMsg
);
2298 if (dlgCode
& DLGC_WANTMESSAGE
) break;
2300 switch(lpMsg
->wParam
)
2303 if (!(dlgCode
& DLGC_WANTTAB
))
2305 SendMessageW(hDlg
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_CLEAR
, UISF_HIDEFOCUS
), 0);
2307 /* I am not sure under which circumstances the TAB is handled
2308 * each way. All I do know is that it does not always simply
2309 * send WM_NEXTDLGCTL. (Personally I have never yet seen it
2310 * do so but I presume someone has)
2312 if (GETDLGINFO(hDlg
))
2313 SendMessageW( hDlg
, WM_NEXTDLGCTL
, (GetKeyState(VK_SHIFT
) & 0x8000), 0 );
2316 /* It would appear that GetNextDlgTabItem can handle being
2317 * passed hwndDlg rather than NULL but that is undocumented
2318 * so let's do it properly
2320 HWND hwndFocus
= GetFocus();
2321 HWND hwndNext
= GetNextDlgTabItem (hDlg
,
2322 hwndFocus
== hDlg
? NULL
: hwndFocus
,
2323 GetKeyState (VK_SHIFT
) & 0x8000);
2326 dlgCode
= SendMessageW (hwndNext
, WM_GETDLGCODE
,
2327 lpMsg
->wParam
, (LPARAM
)lpMsg
);
2328 if (dlgCode
& DLGC_HASSETSEL
)
2330 INT maxlen
= 1 + SendMessageW (hwndNext
, WM_GETTEXTLENGTH
, 0, 0);
2331 WCHAR
*buffer
= HeapAlloc (GetProcessHeap(), 0, maxlen
* sizeof(WCHAR
));
2335 SendMessageW (hwndNext
, WM_GETTEXT
, maxlen
, (LPARAM
) buffer
);
2336 length
= wcslen (buffer
);
2337 HeapFree (GetProcessHeap(), 0, buffer
);
2338 SendMessageW (hwndNext
, EM_SETSEL
, 0, length
);
2341 NtUserSetFocus (hwndNext
);
2342 DIALOG_FixChildrenOnChangeFocus (hDlg
, hwndNext
);
2355 if (!(dlgCode
& DLGC_WANTARROWS
))
2357 BOOL fPrevious
= (lpMsg
->wParam
== VK_LEFT
|| lpMsg
->wParam
== VK_UP
);
2358 HWND hwndNext
= GetNextDlgGroupItem (hDlg
, GetFocus(), fPrevious
);
2359 SendMessageW( hDlg
, WM_NEXTDLGCTL
, (WPARAM
)hwndNext
, 1 );
2366 SendMessageW( hDlg
, WM_COMMAND
, IDCANCEL
, (LPARAM
)GetDlgItem( hDlg
, IDCANCEL
) );
2373 if ((GetFocus() == lpMsg
->hwnd
) &&
2374 (SendMessageW (lpMsg
->hwnd
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
2376 SendMessageW (hDlg
, WM_COMMAND
, MAKEWPARAM (GetDlgCtrlID(lpMsg
->hwnd
),BN_CLICKED
), (LPARAM
)lpMsg
->hwnd
);
2378 else if (DC_HASDEFID
== HIWORD(dw
= SendMessageW (hDlg
, DM_GETDEFID
, 0, 0)))
2380 SendMessageW( hDlg
, WM_COMMAND
, MAKEWPARAM( LOWORD(dw
), BN_CLICKED
),
2381 (LPARAM
)GetDlgItem(hDlg
, LOWORD(dw
)));
2385 SendMessageW( hDlg
, WM_COMMAND
, IDOK
, (LPARAM
)GetDlgItem( hDlg
, IDOK
) );
2394 dlgCode
= SendMessageW( lpMsg
->hwnd
, WM_GETDLGCODE
, lpMsg
->wParam
, (LPARAM
)lpMsg
);
2395 if (dlgCode
& (DLGC_WANTCHARS
|DLGC_WANTMESSAGE
)) break;
2396 if (lpMsg
->wParam
== '\t' && (dlgCode
& DLGC_WANTTAB
)) break;
2400 if (DIALOG_IsAccelerator( lpMsg
->hwnd
, hDlg
, lpMsg
->wParam
))
2402 /* don't translate or dispatch */
2408 /* If the ALT key is being pressed display the keyboard cues */
2409 if (lpMsg
->lParam
& (1 << 29))
2410 SendMessageW(hDlg
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_CLEAR
, UISF_HIDEACCEL
| UISF_HIDEFOCUS
), 0);
2414 TranslateMessage( lpMsg
);
2415 DispatchMessageW( lpMsg
);
2429 return (UINT
)SendDlgItemMessageW( hDlg
, nIDButton
, BM_GETCHECK
, 0, 0 );
2442 DIALOGINFO
* dlgInfo
;
2443 if (!(dlgInfo
= GETDLGINFO(hDlg
))) return FALSE
;
2444 lpRect
->left
= MulDiv(lpRect
->left
, dlgInfo
->xBaseUnit
, 4);
2445 lpRect
->right
= MulDiv(lpRect
->right
, dlgInfo
->xBaseUnit
, 4);
2446 lpRect
->top
= MulDiv(lpRect
->top
, dlgInfo
->yBaseUnit
, 8);
2447 lpRect
->bottom
= MulDiv(lpRect
->bottom
, dlgInfo
->yBaseUnit
, 8);
2457 SendDlgItemMessageA(
2464 HWND hwndCtrl
= GetDlgItem( hDlg
, nIDDlgItem
);
2465 if (hwndCtrl
) return SendMessageA( hwndCtrl
, Msg
, wParam
, lParam
);
2475 SendDlgItemMessageW(
2482 HWND hwndCtrl
= GetDlgItem( hDlg
, nIDDlgItem
);
2483 if (hwndCtrl
) return SendMessageW( hwndCtrl
, Msg
, wParam
, lParam
);
2501 if (bSigned
) sprintf( str
, "%d", (INT
)uValue
);
2502 else sprintf( str
, "%u", uValue
);
2503 SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)str
);
2518 return SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2532 return SendDlgItemMessageW( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2546 SendDlgItemMessageW( hDlg
, nIDButton
, BM_SETCHECK
, uCheck
, 0 );
2550 static BOOL CALLBACK
CheckRB(HWND hwnd
, LPARAM lParam
)
2552 LONG lChildID
= GetWindowLongPtrW(hwnd
, GWLP_ID
);
2553 RADIOGROUP
*lpRadioGroup
= (RADIOGROUP
*)lParam
;
2555 if((lChildID
>= lpRadioGroup
->firstID
) &&
2556 (lChildID
<= lpRadioGroup
->lastID
))
2558 if (lChildID
== lpRadioGroup
->checkID
)
2560 SendMessageW(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
2564 SendMessageW(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
2582 RADIOGROUP radioGroup
;
2584 radioGroup
.firstID
= nIDFirstButton
;
2585 radioGroup
.lastID
= nIDLastButton
;
2586 radioGroup
.checkID
= nIDCheckButton
;
2588 return EnumChildWindows(hDlg
, CheckRB
, (LPARAM
)&radioGroup
);