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) (DIALOGINFO*)GetWindowLongPtrW((hwnd),DWLP_ROS_DIALOGINFO)
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 STDCALL
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 * Helper function for modal dialogs to enable again the
145 * owner of the dialog box.
147 void DIALOG_EnableOwner( HWND hOwner
)
149 /* Owner must be a top-level window */
151 hOwner
= GetAncestor( hOwner
, GA_ROOT
);
153 EnableWindow( hOwner
, TRUE
);
156 /***********************************************************************
157 * DIALOG_DisableOwner
159 * Helper function for modal dialogs to disable the
160 * owner of the dialog box. Returns TRUE if owner was enabled.
162 BOOL
DIALOG_DisableOwner( HWND hOwner
)
164 /* Owner must be a top-level window */
166 hOwner
= GetAncestor( hOwner
, GA_ROOT
);
167 if (!hOwner
) return FALSE
;
168 if (IsWindowEnabled( hOwner
))
170 EnableWindow( hOwner
, FALSE
);
177 /***********************************************************************
178 * DIALOG_GetControl32
180 * Return the class and text of the control pointed to by ptr,
181 * fill the header structure and return a pointer to the next control.
183 static const WORD
*DIALOG_GetControl32( const WORD
*p
, DLG_CONTROL_INFO
*info
,
188 info
->helpId
= GET_DWORD(p
); p
+= 2;
189 info
->exStyle
= GET_DWORD(p
); p
+= 2;
190 info
->style
= GET_DWORD(p
); p
+= 2;
195 info
->style
= GET_DWORD(p
); p
+= 2;
196 info
->exStyle
= GET_DWORD(p
); p
+= 2;
198 info
->x
= GET_WORD(p
); p
++;
199 info
->y
= GET_WORD(p
); p
++;
200 info
->cx
= GET_WORD(p
); p
++;
201 info
->cy
= GET_WORD(p
); p
++;
205 /* id is a DWORD for DIALOGEX */
206 info
->id
= GET_DWORD(p
);
211 info
->id
= GET_WORD(p
);
215 if (GET_WORD(p
) == 0xffff)
217 static const WCHAR class_names
[6][10] =
219 { 'B','u','t','t','o','n', }, /* 0x80 */
220 { 'E','d','i','t', }, /* 0x81 */
221 { 'S','t','a','t','i','c', }, /* 0x82 */
222 { 'L','i','s','t','B','o','x', }, /* 0x83 */
223 { 'S','c','r','o','l','l','B','a','r', }, /* 0x84 */
224 { 'C','o','m','b','o','B','o','x', } /* 0x85 */
226 WORD id
= GET_WORD(p
+1);
227 /* Windows treats dialog control class ids 0-5 same way as 0x80-0x85 */
228 if ((id
>= 0x80) && (id
<= 0x85)) id
-= 0x80;
230 info
->className
= class_names
[id
];
233 info
->className
= NULL
;
234 /* FIXME: load other classes here? */
240 info
->className
= (LPCWSTR
)p
;
241 p
+= wcslen( info
->className
) + 1;
244 if (GET_WORD(p
) == 0xffff) /* Is it an integer id? */
246 info
->windowName
= HeapAlloc( GetProcessHeap(), 0, sizeof(L
"#65535") );
247 swprintf((LPWSTR
)info
->windowName
, L
"#%d", GET_WORD(p
+ 1));
248 info
->windowNameFree
= TRUE
;
253 info
->windowName
= (LPCWSTR
)p
;
254 info
->windowNameFree
= FALSE
;
255 p
+= wcslen( info
->windowName
) + 1;
261 p
+= GET_WORD(p
) / sizeof(WORD
);
263 else info
->data
= NULL
;
266 /* Next control is on dword boundary */
267 return (const WORD
*)((((int)p
) + 3) & ~3);
270 /***********************************************************************
271 * DIALOG_CreateControls32
273 * Create the control windows for a dialog.
275 static BOOL
DIALOG_CreateControls32( HWND hwnd
, LPCSTR
template, const DLG_TEMPLATE
*dlgTemplate
,
276 HINSTANCE hInst
, BOOL unicode
)
278 DIALOGINFO
* dlgInfo
;
279 DLG_CONTROL_INFO info
;
280 HWND hwndCtrl
, hwndDefButton
= 0;
281 INT items
= dlgTemplate
->nbItems
;
283 if (!(dlgInfo
= GETDLGINFO(hwnd
))) return -1;
287 template = (LPCSTR
)DIALOG_GetControl32( (WORD
*)template, &info
,
288 dlgTemplate
->dialogEx
);
290 if (info
.style
& WS_BORDER
)
292 info
.style
&= ~WS_BORDER
;
293 info
.exStyle
|= WS_EX_CLIENTEDGE
;
297 hwndCtrl
= CreateWindowExW( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
298 info
.className
, info
.windowName
,
299 info
.style
| WS_CHILD
,
300 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
301 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
302 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
303 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
304 hwnd
, (HMENU
)info
.id
,
305 hInst
, (LPVOID
)info
.data
);
309 LPSTR
class = (LPSTR
)info
.className
;
310 LPSTR caption
= (LPSTR
)info
.windowName
;
314 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, info
.className
, -1, NULL
, 0, NULL
, NULL
);
315 class = HeapAlloc( GetProcessHeap(), 0, len
);
316 WideCharToMultiByte( CP_ACP
, 0, info
.className
, -1, class, len
, NULL
, NULL
);
320 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, info
.windowName
, -1, NULL
, 0, NULL
, NULL
);
321 caption
= HeapAlloc( GetProcessHeap(), 0, len
);
322 WideCharToMultiByte( CP_ACP
, 0, info
.windowName
, -1, caption
, len
, NULL
, NULL
);
324 hwndCtrl
= CreateWindowExA( info
.exStyle
| WS_EX_NOPARENTNOTIFY
,
325 class, caption
, info
.style
| WS_CHILD
,
326 MulDiv(info
.x
, dlgInfo
->xBaseUnit
, 4),
327 MulDiv(info
.y
, dlgInfo
->yBaseUnit
, 8),
328 MulDiv(info
.cx
, dlgInfo
->xBaseUnit
, 4),
329 MulDiv(info
.cy
, dlgInfo
->yBaseUnit
, 8),
330 hwnd
, (HMENU
)info
.id
,
331 hInst
, (LPVOID
)info
.data
);
332 if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
333 if (HIWORD(caption
)) HeapFree( GetProcessHeap(), 0, caption
);
336 if (info
.windowNameFree
)
338 HeapFree( GetProcessHeap(), 0, (LPVOID
)info
.windowName
);
343 if (dlgTemplate
->style
& DS_NOFAILCREATE
) continue;
347 /* Send initialisation messages to the control */
348 if (dlgInfo
->hUserFont
) SendMessageW( hwndCtrl
, WM_SETFONT
,
349 (WPARAM
)dlgInfo
->hUserFont
, 0 );
350 if (SendMessageW(hwndCtrl
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
)
352 /* If there's already a default push-button, set it back */
353 /* to normal and use this one instead. */
355 SendMessageW( hwndDefButton
, BM_SETSTYLE
, BS_PUSHBUTTON
, FALSE
);
356 hwndDefButton
= hwndCtrl
;
357 dlgInfo
->idResult
= GetWindowLongPtrA( hwndCtrl
, GWLP_ID
);
363 /***********************************************************************
364 * DIALOG_FindMsgDestination
366 * The messages that IsDialogMessage sends may not go to the dialog
367 * calling IsDialogMessage if that dialog is a child, and it has the
368 * DS_CONTROL style set.
369 * We propagate up until we hit one that does not have DS_CONTROL, or
370 * whose parent is not a dialog.
372 * This is undocumented behaviour.
374 static HWND
DIALOG_FindMsgDestination( HWND hwndDlg
)
376 while (GetWindowLongA(hwndDlg
, GWL_STYLE
) & DS_CONTROL
)
378 HWND hParent
= GetParent(hwndDlg
);
381 if (!IsWindow(hParent
)) break;
383 if (!GETDLGINFO(hParent
)) /* TODO: Correct? */
394 /***********************************************************************
395 * DIALOG_IsAccelerator
397 static BOOL
DIALOG_IsAccelerator( HWND hwnd
, HWND hwndDlg
, WPARAM wParam
)
399 HWND hwndControl
= hwnd
;
406 DWORD style
= GetWindowLongW( hwndControl
, GWL_STYLE
);
407 if ((style
& (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
)
409 dlgCode
= SendMessageA( hwndControl
, WM_GETDLGCODE
, 0, 0 );
410 if ( (dlgCode
& (DLGC_BUTTON
| DLGC_STATIC
)) &&
411 GetWindowTextW( hwndControl
, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
413 /* find the accelerator key */
414 LPWSTR p
= buffer
- 2;
418 p
= wcschr( p
+ 2, '&' );
420 while (p
!= NULL
&& p
[1] == '&');
422 /* and check if it's the one we're looking for */
423 /* FIXME: usage of towupper correct? */
424 if (p
!= NULL
&& towupper( p
[1] ) == towupper( wParam
) )
426 if ((dlgCode
& DLGC_STATIC
) || (style
& 0x0f) == BS_GROUPBOX
)
428 /* set focus to the control */
429 SendMessageW( hwndDlg
, WM_NEXTDLGCTL
, (WPARAM
)hwndControl
, 1);
430 /* and bump it on to next */
431 SendMessageW( hwndDlg
, WM_NEXTDLGCTL
, 0, 0);
433 else if (dlgCode
& DLGC_BUTTON
)
435 /* send BM_CLICK message to the control */
436 SendMessageW( hwndControl
, BM_CLICK
, 0, 0 );
441 hwndNext
= GetWindow( hwndControl
, GW_CHILD
);
445 if (!hwndNext
) hwndNext
= GetWindow( hwndControl
, GW_HWNDNEXT
);
447 while (!hwndNext
&& hwndControl
)
449 hwndControl
= GetParent( hwndControl
);
450 if (hwndControl
== hwndDlg
)
452 if(hwnd
==hwndDlg
) /* prevent endless loop */
457 hwndNext
= GetWindow( hwndDlg
, GW_CHILD
);
460 hwndNext
= GetWindow( hwndControl
, GW_HWNDNEXT
);
462 hwndControl
= hwndNext
;
464 while (hwndControl
&& (hwndControl
!= hwnd
));
469 /***********************************************************************
472 INT
DIALOG_DoDialogBox( HWND hwnd
, HWND owner
)
474 DIALOGINFO
* dlgInfo
;
477 HWND ownerMsg
= GetAncestor( owner
, GA_ROOT
);
480 if (!(dlgInfo
= GETDLGINFO(hwnd
))) return -1;
483 if (!(dlgInfo
->flags
& DF_END
)) /* was EndDialog called in WM_INITDIALOG ? */
487 if (!PeekMessageW( &msg
, 0, 0, 0, PM_REMOVE
))
491 /* ShowWindow the first time the queue goes empty */
492 ShowWindow( hwnd
, SW_SHOWNORMAL
);
495 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & DS_NOIDLEMSG
))
497 /* No message present -> send ENTERIDLE and wait */
498 SendMessageW( ownerMsg
, WM_ENTERIDLE
, MSGF_DIALOGBOX
, (LPARAM
)hwnd
);
500 if (!GetMessageW( &msg
, 0, 0, 0 )) break;
503 if (!IsWindow( hwnd
)) return -1;
504 if (!(dlgInfo
->flags
& DF_END
) && !IsDialogMessageW( hwnd
, &msg
))
506 TranslateMessage( &msg
);
507 DispatchMessageW( &msg
);
509 if (dlgInfo
->flags
& DF_END
) break;
512 if (dlgInfo
->flags
& DF_OWNERENABLED
) DIALOG_EnableOwner( owner
);
513 retval
= dlgInfo
->idResult
;
514 DestroyWindow( hwnd
);
518 /***********************************************************************
519 * DIALOG_ParseTemplate32
521 * Fill a DLG_TEMPLATE structure from the dialog template, and return
522 * a pointer to the first control.
524 static LPCSTR
DIALOG_ParseTemplate32( LPCSTR
template, DLG_TEMPLATE
* result
)
526 const WORD
*p
= (const WORD
*)template;
530 signature
= GET_WORD(p
); p
++;
531 dlgver
= GET_WORD(p
); p
++;
533 if (signature
== 1 && dlgver
== 0xffff) /* DIALOGEX resource */
535 result
->dialogEx
= TRUE
;
536 result
->helpId
= GET_DWORD(p
); p
+= 2;
537 result
->exStyle
= GET_DWORD(p
); p
+= 2;
538 result
->style
= GET_DWORD(p
); p
+= 2;
542 result
->style
= GET_DWORD(p
- 2);
543 result
->dialogEx
= FALSE
;
545 result
->exStyle
= GET_DWORD(p
); p
+= 2;
547 result
->nbItems
= GET_WORD(p
); p
++;
548 result
->x
= GET_WORD(p
); p
++;
549 result
->y
= GET_WORD(p
); p
++;
550 result
->cx
= GET_WORD(p
); p
++;
551 result
->cy
= GET_WORD(p
); p
++;
553 /* Get the menu name */
558 result
->menuName
= NULL
;
562 result
->menuName
= (LPCWSTR
)(UINT
)GET_WORD( p
+ 1 );
566 result
->menuName
= (LPCWSTR
)p
;
567 p
+= wcslen( result
->menuName
) + 1;
571 /* Get the class name */
576 result
->className
= DIALOG_CLASS_ATOMW
;
580 result
->className
= (LPCWSTR
)(UINT
)GET_WORD( p
+ 1 );
584 result
->className
= (LPCWSTR
)p
;
585 p
+= wcslen( result
->className
) + 1;
589 /* Get the window caption */
591 result
->caption
= (LPCWSTR
)p
;
592 p
+= wcslen( result
->caption
) + 1;
594 /* Get the font name */
596 result
->pointSize
= 0;
597 result
->weight
= FW_DONTCARE
;
598 result
->italic
= FALSE
;
599 result
->faceName
= NULL
;
601 if (result
->style
& DS_SETFONT
)
603 result
->pointSize
= GET_WORD(p
);
605 if (result
->dialogEx
)
607 result
->weight
= GET_WORD(p
); p
++;
608 result
->italic
= LOBYTE(GET_WORD(p
)); p
++;
610 result
->faceName
= (LPCWSTR
)p
;
611 p
+= wcslen( result
->faceName
) + 1;
614 /* First control is on dword boundary */
615 return (LPCSTR
)((((UINT_PTR
)p
) + 3) & ~3);
618 /***********************************************************************
619 * DIALOG_CreateIndirect
620 * Creates a dialog box window
622 * modal = TRUE if we are called from a modal dialog box.
623 * (it's more compatible to do it here, as under Windows the owner
624 * is never disabled if the dialog fails because of an invalid template)
626 static HWND
DIALOG_CreateIndirect( HINSTANCE hInst
, LPCVOID dlgTemplate
,
627 HWND owner
, DLGPROC dlgProc
, LPARAM param
,
628 BOOL unicode
, BOOL modal
)
632 DLG_TEMPLATE
template;
633 DIALOGINFO
* dlgInfo
= NULL
;
634 DWORD units
= GetDialogBaseUnits();
635 BOOL ownerEnabled
= TRUE
;
639 UINT xBaseUnit
= LOWORD(units
);
640 UINT yBaseUnit
= HIWORD(units
);
642 /* Parse dialog template */
644 if (!dlgTemplate
) return 0;
645 dlgTemplate
= DIALOG_ParseTemplate32( dlgTemplate
, &template );
649 if (template.menuName
) hMenu
= LoadMenuW( hInst
, template.menuName
);
651 /* Create custom font if needed */
653 if (template.style
& DS_SETFONT
)
655 /* We convert the size to pixels and then make it -ve. This works
656 * for both +ve and -ve template.pointSize */
660 pixels
= MulDiv(template.pointSize
, GetDeviceCaps(dc
, LOGPIXELSY
), 72);
661 hUserFont
= CreateFontW( -pixels
, 0, 0, 0, template.weight
,
662 template.italic
, FALSE
, FALSE
, DEFAULT_CHARSET
, 0, 0,
663 PROOF_QUALITY
, FF_DONTCARE
,
668 HFONT hOldFont
= SelectObject( dc
, hUserFont
);
669 charSize
.cx
= GdiGetCharDimensions( dc
, NULL
, &charSize
.cy
);
672 xBaseUnit
= charSize
.cx
;
673 yBaseUnit
= charSize
.cy
;
675 SelectObject( dc
, hOldFont
);
678 TRACE("units = %d,%d\n", xBaseUnit
, yBaseUnit
);
681 /* Create dialog main window */
683 rect
.left
= rect
.top
= 0;
684 rect
.right
= MulDiv(template.cx
, xBaseUnit
, 4);
685 rect
.bottom
= MulDiv(template.cy
, yBaseUnit
, 8);
686 if (template.style
& WS_CHILD
)
687 template.style
&= ~(WS_CAPTION
|WS_SYSMENU
);
688 if (template.style
& DS_MODALFRAME
)
689 template.exStyle
|= WS_EX_DLGMODALFRAME
;
690 if (template.style
& DS_CONTROL
)
691 template.exStyle
|= WS_EX_CONTROLPARENT
;
692 AdjustWindowRectEx( &rect
, template.style
, (hMenu
!= 0), template.exStyle
);
693 rect
.right
-= rect
.left
;
694 rect
.bottom
-= rect
.top
;
696 if (template.x
== CW_USEDEFAULT16
)
698 rect
.left
= rect
.top
= CW_USEDEFAULT
;
702 if (template.style
& DS_CENTER
)
704 rect
.left
= (GetSystemMetrics(SM_CXSCREEN
) - rect
.right
) / 2;
705 rect
.top
= (GetSystemMetrics(SM_CYSCREEN
) - rect
.bottom
) / 2;
709 rect
.left
+= MulDiv(template.x
, xBaseUnit
, 4);
710 rect
.top
+= MulDiv(template.y
, yBaseUnit
, 8);
712 if ( !(template.style
& WS_CHILD
) )
716 if( !(template.style
& DS_ABSALIGN
) )
717 ClientToScreen( owner
, (POINT
*)&rect
);
719 /* try to fit it into the desktop */
721 if( (dX
= rect
.left
+ rect
.right
+ GetSystemMetrics(SM_CXDLGFRAME
)
722 - GetSystemMetrics(SM_CXSCREEN
)) > 0 ) rect
.left
-= dX
;
723 if( (dY
= rect
.top
+ rect
.bottom
+ GetSystemMetrics(SM_CYDLGFRAME
)
724 - GetSystemMetrics(SM_CYSCREEN
)) > 0 ) rect
.top
-= dY
;
725 if( rect
.left
< 0 ) rect
.left
= 0;
726 if( rect
.top
< 0 ) rect
.top
= 0;
732 ownerEnabled
= DIALOG_DisableOwner( owner
);
733 if (ownerEnabled
) flags
|= DF_OWNERENABLED
;
738 hwnd
= User32CreateWindowEx(template.exStyle
, (LPCSTR
)template.className
, (LPCSTR
)template.caption
,
739 template.style
& ~WS_VISIBLE
,
740 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
741 owner
, hMenu
, hInst
, NULL
,
746 LPSTR
class = (LPSTR
)template.className
;
747 LPSTR caption
= (LPSTR
)template.caption
;
751 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, template.className
, -1, NULL
, 0, NULL
, NULL
);
752 class = HeapAlloc( GetProcessHeap(), 0, len
);
753 WideCharToMultiByte( CP_ACP
, 0, template.className
, -1, class, len
, NULL
, NULL
);
757 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, template.caption
, -1, NULL
, 0, NULL
, NULL
);
758 caption
= HeapAlloc( GetProcessHeap(), 0, len
);
759 WideCharToMultiByte( CP_ACP
, 0, template.caption
, -1, caption
, len
, NULL
, NULL
);
761 hwnd
= User32CreateWindowEx(template.exStyle
, class, caption
,
762 template.style
& ~WS_VISIBLE
,
763 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
764 owner
, hMenu
, hInst
, NULL
,
766 if (HIWORD(class)) HeapFree( GetProcessHeap(), 0, class );
767 if (HIWORD(caption
)) HeapFree( GetProcessHeap(), 0, caption
);
772 if (hUserFont
) DeleteObject( hUserFont
);
773 if (hMenu
) DestroyMenu( hMenu
);
774 if (modal
&& (flags
& DF_OWNERENABLED
)) DIALOG_EnableOwner(owner
);
778 /* moved this from the top of the method to here as DIALOGINFO structure
779 will be valid only after WM_CREATE message has been handled in DefDlgProc
780 All the members of the structure get filled here using temp variables */
782 // dlgInfo = DIALOG_get_info( hwnd, TRUE );
784 if (!(dlgInfo
= HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo
) ))) return 0;
785 SETDLGINFO(hwnd
, dlgInfo
);
787 dlgInfo
->hwndFocus
= 0;
788 dlgInfo
->hUserFont
= hUserFont
;
789 dlgInfo
->hMenu
= hMenu
;
790 dlgInfo
->xBaseUnit
= xBaseUnit
;
791 dlgInfo
->yBaseUnit
= yBaseUnit
;
792 dlgInfo
->idResult
= 0;
793 dlgInfo
->flags
= flags
;
794 // dlgInfo->hDialogHeap = 0;
796 if (template.helpId
) SetWindowContextHelpId( hwnd
, template.helpId
);
798 if (unicode
) SetWindowLongPtrW( hwnd
, DWLP_DLGPROC
, (ULONG_PTR
)dlgProc
);
799 else SetWindowLongPtrA( hwnd
, DWLP_DLGPROC
, (ULONG_PTR
)dlgProc
);
801 if (dlgInfo
->hUserFont
)
802 SendMessageW( hwnd
, WM_SETFONT
, (WPARAM
)dlgInfo
->hUserFont
, 0 );
804 /* Create controls */
806 if (DIALOG_CreateControls32( hwnd
, dlgTemplate
, &template, hInst
, unicode
))
808 /* Send initialisation messages and set focus */
810 if (SendMessageW( hwnd
, WM_INITDIALOG
, (WPARAM
)dlgInfo
->hwndFocus
, param
) &&
811 ((~template.style
& DS_CONTROL
) || (template.style
& WS_VISIBLE
)))
813 /* By returning TRUE, app has requested a default focus assignment */
814 dlgInfo
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
815 if( dlgInfo
->hwndFocus
)
816 SetFocus( dlgInfo
->hwndFocus
);
819 if (!(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_CHILD
))
820 SendMessageW( hwnd
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_INITIALIZE
, 0), 0);
822 if (template.style
& WS_VISIBLE
&& !(GetWindowLongW( hwnd
, GWL_STYLE
) & WS_VISIBLE
))
824 ShowWindow( hwnd
, SW_SHOWNORMAL
); /* SW_SHOW doesn't always work */
828 if (modal
&& ownerEnabled
) DIALOG_EnableOwner(owner
);
829 if( IsWindow(hwnd
) ) DestroyWindow( hwnd
);
833 /***********************************************************************
836 * Set the focus to a control of the dialog, selecting the text if
837 * the control is an edit dialog.
839 static void DEFDLG_SetFocus( HWND hwndDlg
, HWND hwndCtrl
)
841 HWND hwndPrev
= GetFocus();
843 if (IsChild( hwndDlg
, hwndPrev
))
845 if (SendMessageW( hwndPrev
, WM_GETDLGCODE
, 0, 0 ) & DLGC_HASSETSEL
)
846 SendMessageW( hwndPrev
, EM_SETSEL
, -1, 0 );
848 if (SendMessageW( hwndCtrl
, WM_GETDLGCODE
, 0, 0 ) & DLGC_HASSETSEL
)
849 SendMessageW( hwndCtrl
, EM_SETSEL
, 0, -1 );
850 SetFocus( hwndCtrl
);
853 /***********************************************************************
856 static void DEFDLG_SaveFocus( HWND hwnd
)
859 HWND hwndFocus
= GetFocus();
861 if (!hwndFocus
|| !IsChild( hwnd
, hwndFocus
)) return;
862 if (!(infoPtr
= GETDLGINFO(hwnd
))) return;
863 infoPtr
->hwndFocus
= hwndFocus
;
864 /* Remove default button */
867 /***********************************************************************
868 * DEFDLG_RestoreFocus
870 static void DEFDLG_RestoreFocus( HWND hwnd
)
874 if (IsIconic( hwnd
)) return;
875 if (!(infoPtr
= GETDLGINFO(hwnd
))) return;
876 /* Don't set the focus back to controls if EndDialog is already called.*/
877 if (infoPtr
->flags
& DF_END
) return;
878 if (!IsWindow(infoPtr
->hwndFocus
) || infoPtr
->hwndFocus
== hwnd
) {
879 /* If no saved focus control exists, set focus to the first visible,
880 non-disabled, WS_TABSTOP control in the dialog */
881 infoPtr
->hwndFocus
= GetNextDlgTabItem( hwnd
, 0, FALSE
);
882 if (!IsWindow( infoPtr
->hwndFocus
)) return;
884 SetFocus( infoPtr
->hwndFocus
);
886 /* This used to set infoPtr->hwndFocus to NULL for no apparent reason,
887 sometimes losing focus when receiving WM_SETFOCUS messages. */
890 /***********************************************************************
891 * DEFDLG_FindDefButton
893 * Find the current default push-button.
895 static HWND
DEFDLG_FindDefButton( HWND hwndDlg
)
897 HWND hwndChild
, hwndTmp
;
899 hwndChild
= GetWindow( hwndDlg
, GW_CHILD
);
902 if (SendMessageW( hwndChild
, WM_GETDLGCODE
, 0, 0 ) & DLGC_DEFPUSHBUTTON
)
905 /* Recurse into WS_EX_CONTROLPARENT controls */
906 if (GetWindowLongW( hwndChild
, GWL_EXSTYLE
) & WS_EX_CONTROLPARENT
)
908 LONG dsStyle
= GetWindowLongW( hwndChild
, GWL_STYLE
);
909 if ((dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
) &&
910 (hwndTmp
= DEFDLG_FindDefButton(hwndChild
)) != NULL
)
913 hwndChild
= GetWindow( hwndChild
, GW_HWNDNEXT
);
918 /***********************************************************************
921 * Set the default button id.
923 static BOOL
DEFDLG_SetDefId( HWND hwndDlg
, DIALOGINFO
*dlgInfo
, WPARAM wParam
)
925 DWORD dlgcode
=0; /* initialize just to avoid a warning */
926 HWND hwndOld
, hwndNew
= GetDlgItem(hwndDlg
, wParam
);
927 INT old_id
= dlgInfo
->idResult
;
929 dlgInfo
->idResult
= wParam
;
931 !((dlgcode
=SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 ))
932 & (DLGC_UNDEFPUSHBUTTON
| DLGC_BUTTON
)))
933 return FALSE
; /* Destination is not a push button */
935 /* Make sure the old default control is a valid push button ID */
936 hwndOld
= GetDlgItem( hwndDlg
, old_id
);
937 if (!hwndOld
|| !(SendMessageW( hwndOld
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
938 hwndOld
= DEFDLG_FindDefButton( hwndDlg
);
939 if (hwndOld
&& hwndOld
!= hwndNew
)
940 SendMessageW( hwndOld
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
944 if(dlgcode
& DLGC_UNDEFPUSHBUTTON
)
945 SendMessageW( hwndNew
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
950 /***********************************************************************
951 * DEFDLG_SetDefButton
953 * Set the new default button to be hwndNew.
955 static BOOL
DEFDLG_SetDefButton( HWND hwndDlg
, DIALOGINFO
*dlgInfo
, HWND hwndNew
)
957 DWORD dlgcode
=0; /* initialize just to avoid a warning */
958 HWND hwndOld
= GetDlgItem( hwndDlg
, dlgInfo
->idResult
);
961 !((dlgcode
=SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 ))
962 & (DLGC_UNDEFPUSHBUTTON
| DLGC_DEFPUSHBUTTON
)))
965 * Need to draw only default push button rectangle.
966 * Since the next control is not a push button, need to draw the push
967 * button rectangle for the default control.
970 dlgcode
= SendMessageW(hwndNew
, WM_GETDLGCODE
, 0, 0 );
973 /* Make sure the old default control is a valid push button ID */
974 if (!hwndOld
|| !(SendMessageW( hwndOld
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
975 hwndOld
= DEFDLG_FindDefButton( hwndDlg
);
976 if (hwndOld
&& hwndOld
!= hwndNew
)
977 SendMessageW( hwndOld
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
981 if(dlgcode
& DLGC_UNDEFPUSHBUTTON
)
982 SendMessageW( hwndNew
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
987 /***********************************************************************
990 * Implementation of DefDlgProc(). Only handle messages that need special
991 * handling for dialogs.
993 static LRESULT
DEFDLG_Proc( HWND hwnd
, UINT msg
, WPARAM wParam
,
994 LPARAM lParam
, DIALOGINFO
*dlgInfo
)
1000 HBRUSH brush
= (HBRUSH
)SendMessageW( hwnd
, WM_CTLCOLORDLG
, wParam
, (LPARAM
)hwnd
);
1001 if (!brush
) brush
= (HBRUSH
)DefWindowProcW( hwnd
, WM_CTLCOLORDLG
, wParam
, (LPARAM
)hwnd
);
1005 HDC hdc
= (HDC
)wParam
;
1006 GetClientRect( hwnd
, &rect
);
1007 DPtoLP( hdc
, (LPPOINT
)&rect
, 2 );
1008 FillRect( hdc
, &rect
, brush
);
1013 if ((dlgInfo
= (DIALOGINFO
*)SetWindowLongPtrW( hwnd
, DWLP_ROS_DIALOGINFO
, 0 )))
1015 /* Free dialog heap (if created) */
1016 /*if (dlgInfo->hDialogHeap)
1018 GlobalUnlock16(dlgInfo->hDialogHeap);
1019 GlobalFree16(dlgInfo->hDialogHeap);
1021 if (dlgInfo
->hUserFont
) DeleteObject( dlgInfo
->hUserFont
);
1022 if (dlgInfo
->hMenu
) DestroyMenu( dlgInfo
->hMenu
);
1023 HeapFree( GetProcessHeap(), 0, dlgInfo
);
1025 /* Window clean-up */
1026 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1029 if (!wParam
) DEFDLG_SaveFocus( hwnd
);
1030 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1033 if (wParam
) DEFDLG_RestoreFocus( hwnd
);
1034 else DEFDLG_SaveFocus( hwnd
);
1038 DEFDLG_RestoreFocus( hwnd
);
1042 if (dlgInfo
&& !(dlgInfo
->flags
& DF_END
))
1043 DEFDLG_SetDefId( hwnd
, dlgInfo
, wParam
);
1047 if (dlgInfo
&& !(dlgInfo
->flags
& DF_END
))
1050 if (dlgInfo
->idResult
)
1051 return MAKELONG( dlgInfo
->idResult
, DC_HASDEFID
);
1052 if ((hwndDefId
= DEFDLG_FindDefButton( hwnd
)))
1053 return MAKELONG( GetDlgCtrlID( hwndDefId
), DC_HASDEFID
);
1060 HWND hwndDest
= (HWND
)wParam
;
1062 hwndDest
= GetNextDlgTabItem(hwnd
, GetFocus(), wParam
);
1063 if (hwndDest
) DEFDLG_SetFocus( hwnd
, hwndDest
);
1064 DEFDLG_SetDefButton( hwnd
, dlgInfo
, hwndDest
);
1068 case WM_ENTERMENULOOP
:
1069 case WM_LBUTTONDOWN
:
1070 case WM_NCLBUTTONDOWN
:
1072 HWND hwndFocus
= GetFocus();
1075 /* always make combo box hide its listbox control */
1076 if (!SendMessageW( hwndFocus
, CB_SHOWDROPDOWN
, FALSE
, 0 ))
1077 SendMessageW( GetParent(hwndFocus
), CB_SHOWDROPDOWN
, FALSE
, 0 );
1080 return DefWindowProcA( hwnd
, msg
, wParam
, lParam
);
1083 return dlgInfo
? (LRESULT
)dlgInfo
->hUserFont
: 0;
1086 PostMessageA( hwnd
, WM_COMMAND
, MAKEWPARAM(IDCANCEL
, BN_CLICKED
),
1087 (LPARAM
)GetDlgItem( hwnd
, IDCANCEL
) );
1093 /***********************************************************************
1096 static LRESULT
DEFDLG_Epilog(HWND hwnd
, UINT msg
, BOOL fResult
)
1099 // TODO: where's wine's WM_CTLCOLOR from?
1100 if ((msg
>= WM_CTLCOLORMSGBOX
&& msg
<= WM_CTLCOLORSTATIC
) ||
1101 msg
== WM_CTLCOLOR
|| msg
== WM_COMPAREITEM
||
1102 msg
== WM_VKEYTOITEM
|| msg
== WM_CHARTOITEM
||
1103 msg
== WM_QUERYDRAGICON
|| msg
== WM_INITDIALOG
)
1106 return GetWindowLongPtrW( hwnd
, DWLP_MSGRESULT
);
1109 /***********************************************************************
1110 * DIALOG_GetNextTabItem
1112 * Helper for GetNextDlgTabItem
1114 static HWND
DIALOG_GetNextTabItem( HWND hwndMain
, HWND hwndDlg
, HWND hwndCtrl
, BOOL fPrevious
)
1118 UINT wndSearch
= fPrevious
? GW_HWNDPREV
: GW_HWNDNEXT
;
1120 HWND hChildFirst
= 0;
1124 hChildFirst
= GetWindow(hwndDlg
,GW_CHILD
);
1125 if(fPrevious
) hChildFirst
= GetWindow(hChildFirst
,GW_HWNDLAST
);
1127 else if (IsChild( hwndMain
, hwndCtrl
))
1129 hChildFirst
= GetWindow(hwndCtrl
,wndSearch
);
1132 if(GetParent(hwndCtrl
) != hwndMain
)
1133 /* i.e. if we are not at the top level of the recursion */
1134 hChildFirst
= GetWindow(GetParent(hwndCtrl
),wndSearch
);
1136 hChildFirst
= GetWindow(hwndCtrl
, fPrevious
? GW_HWNDLAST
: GW_HWNDFIRST
);
1142 dsStyle
= GetWindowLongA(hChildFirst
,GWL_STYLE
);
1143 exStyle
= GetWindowLongA(hChildFirst
,GWL_EXSTYLE
);
1144 if( (exStyle
& WS_EX_CONTROLPARENT
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
1147 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hChildFirst
,NULL
,fPrevious
);
1148 if (retWnd
) return (retWnd
);
1150 else if( (dsStyle
& WS_TABSTOP
) && (dsStyle
& WS_VISIBLE
) && !(dsStyle
& WS_DISABLED
))
1152 return (hChildFirst
);
1154 hChildFirst
= GetWindow(hChildFirst
,wndSearch
);
1158 HWND hParent
= GetParent(hwndCtrl
);
1161 if(hParent
== hwndMain
) break;
1162 retWnd
= DIALOG_GetNextTabItem(hwndMain
,GetParent(hParent
),hParent
,fPrevious
);
1164 hParent
= GetParent(hParent
);
1167 retWnd
= DIALOG_GetNextTabItem(hwndMain
,hwndMain
,NULL
,fPrevious
);
1169 return retWnd
? retWnd
: hwndCtrl
;
1173 /**********************************************************************
1174 * DIALOG_DlgDirListW
1176 * Helper function for DlgDirList*W
1178 static INT
DIALOG_DlgDirListW( HWND hDlg
, LPWSTR spec
, INT idLBox
,
1179 INT idStatic
, UINT attrib
, BOOL combo
)
1182 LPWSTR orig_spec
= spec
;
1183 WCHAR any
[] = {'*','.','*',0};
1185 #define SENDMSG(msg,wparam,lparam) \
1186 ((attrib & DDL_POSTMSGS) ? PostMessageW( hwnd, msg, wparam, lparam ) \
1187 : SendMessageW( hwnd, msg, wparam, lparam ))
1189 // TRACE("%p '%s' %d %d %04x\n",
1190 // hDlg, spec ? spec : "NULL", idLBox, idStatic, attrib );
1192 /* If the path exists and is a directory, chdir to it */
1193 if (!spec
|| !spec
[0] || SetCurrentDirectoryW( spec
)) spec
= any
;
1198 if ((p2
= strrchrW( p
, '\\' ))) p
= p2
;
1199 if ((p2
= strrchrW( p
, '/' ))) p
= p2
;
1204 if (!SetCurrentDirectoryW( spec
))
1206 *p
= sep
; /* Restore the original spec */
1213 TRACE( "mask=%s\n", spec
);
1215 if (idLBox
&& ((hwnd
= GetDlgItem( hDlg
, idLBox
)) != 0))
1217 SENDMSG( combo
? CB_RESETCONTENT
: LB_RESETCONTENT
, 0, 0 );
1218 if (attrib
& DDL_DIRECTORY
)
1220 if (!(attrib
& DDL_EXCLUSIVE
))
1222 if (SENDMSG( combo
? CB_DIR
: LB_DIR
,
1223 attrib
& ~(DDL_DIRECTORY
| DDL_DRIVES
),
1224 (LPARAM
)spec
) == LB_ERR
)
1227 if (SENDMSG( combo
? CB_DIR
: LB_DIR
,
1228 (attrib
& (DDL_DIRECTORY
| DDL_DRIVES
)) | DDL_EXCLUSIVE
,
1229 (LPARAM
)any
) == LB_ERR
)
1234 if (SENDMSG( combo
? CB_DIR
: LB_DIR
, attrib
,
1235 (LPARAM
)spec
) == LB_ERR
)
1240 if (idStatic
&& ((hwnd
= GetDlgItem( hDlg
, idStatic
)) != 0))
1242 WCHAR temp
[MAX_PATH
];
1243 GetCurrentDirectoryW( sizeof(temp
)/sizeof(WCHAR
), temp
);
1245 /* Can't use PostMessage() here, because the string is on the stack */
1246 SetDlgItemTextW( hDlg
, idStatic
, temp
);
1249 if (orig_spec
&& (spec
!= orig_spec
))
1251 /* Update the original file spec */
1253 while ((*orig_spec
++ = *p
++));
1260 /**********************************************************************
1261 * DIALOG_DlgDirListA
1263 * Helper function for DlgDirList*A
1265 static INT
DIALOG_DlgDirListA( HWND hDlg
, LPSTR spec
, INT idLBox
,
1266 INT idStatic
, UINT attrib
, BOOL combo
)
1270 INT ret
, len
= MultiByteToWideChar( CP_ACP
, 0, spec
, -1, NULL
, 0 );
1271 LPWSTR specW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
1272 MultiByteToWideChar( CP_ACP
, 0, spec
, -1, specW
, len
);
1273 ret
= DIALOG_DlgDirListW( hDlg
, specW
, idLBox
, idStatic
, attrib
, combo
);
1274 WideCharToMultiByte( CP_ACP
, 0, specW
, -1, spec
, 0x7fffffff, NULL
, NULL
);
1275 HeapFree( GetProcessHeap(), 0, specW
);
1278 return DIALOG_DlgDirListW( hDlg
, NULL
, idLBox
, idStatic
, attrib
, combo
);
1281 /**********************************************************************
1282 * DIALOG_DlgDirSelect
1284 * Helper function for DlgDirSelect*
1286 static BOOL
DIALOG_DlgDirSelect( HWND hwnd
, LPWSTR str
, INT len
,
1287 INT id
, BOOL unicode
, BOOL combo
)
1289 WCHAR
*buffer
, *ptr
;
1292 HWND listbox
= GetDlgItem( hwnd
, id
);
1294 TRACE("%p '%s' %d\n", hwnd
, str
, id
);
1295 if (!listbox
) return FALSE
;
1297 item
= SendMessageW(listbox
, combo
? CB_GETCURSEL
: LB_GETCURSEL
, 0, 0 );
1298 if (item
== LB_ERR
) return FALSE
;
1299 size
= SendMessageW(listbox
, combo
? CB_GETLBTEXTLEN
: LB_GETTEXTLEN
, 0, 0 );
1300 if (size
== LB_ERR
) return FALSE
;
1302 if (!(buffer
= HeapAlloc( GetProcessHeap(), 0, size
+1 ))) return FALSE
;
1304 SendMessageW( listbox
, combo
? CB_GETLBTEXT
: LB_GETTEXT
, item
, (LPARAM
)buffer
);
1306 if ((ret
= (buffer
[0] == '['))) /* drive or directory */
1308 if (buffer
[1] == '-') /* drive */
1316 buffer
[strlenW(buffer
)-1] = '\\';
1324 if (len
> 0 && !WideCharToMultiByte( CP_ACP
, 0, ptr
, -1, (LPSTR
)str
, len
, 0, 0 ))
1325 ((LPSTR
)str
)[len
-1] = 0;
1327 else lstrcpynW( str
, ptr
, len
);
1328 HeapFree( GetProcessHeap(), 0, buffer
);
1329 TRACE("Returning %d '%s'\n", ret
, str
);
1333 /***********************************************************************
1334 * GetDlgItemEnumProc
1336 * Callback for GetDlgItem
1338 BOOL CALLBACK
GetDlgItemEnumProc (HWND hwnd
, LPARAM lParam
)
1340 GETDLGITEMINFO
* info
= (GETDLGITEMINFO
*)lParam
;
1341 if(info
->nIDDlgItem
== GetWindowLongW( hwnd
, GWL_ID
))
1343 info
->control
= hwnd
;
1350 /* FUNCTIONS *****************************************************************/
1357 CreateDialogIndirectParamAorW(
1358 HINSTANCE hInstance
,
1359 LPCDLGTEMPLATE lpTemplate
,
1361 DLGPROC lpDialogFunc
,
1366 * This function might be obsolete since I don't think it is exported by NT
1367 * Also wine has one more parameter identifying weather it should call
1368 * the function with unicode or not
1370 return DIALOG_CreateIndirect( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, !Flags
, FALSE
);
1379 CreateDialogIndirectParamA(
1380 HINSTANCE hInstance
,
1381 LPCDLGTEMPLATE lpTemplate
,
1383 DLGPROC lpDialogFunc
,
1386 return CreateDialogIndirectParamAorW( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, 2 );
1395 CreateDialogIndirectParamW(
1396 HINSTANCE hInstance
,
1397 LPCDLGTEMPLATE lpTemplate
,
1399 DLGPROC lpDialogFunc
,
1402 return CreateDialogIndirectParamAorW( hInstance
, lpTemplate
, hWndParent
, lpDialogFunc
, lParamInit
, 0);
1412 HINSTANCE hInstance
,
1413 LPCSTR lpTemplateName
,
1415 DLGPROC lpDialogFunc
,
1421 if (!(hrsrc
= FindResourceA( hInstance
, lpTemplateName
, (LPCSTR
)RT_DIALOG
))) return 0;
1422 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1423 return CreateDialogIndirectParamA( hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
);
1433 HINSTANCE hInstance
,
1434 LPCWSTR lpTemplateName
,
1436 DLGPROC lpDialogFunc
,
1442 if (!(hrsrc
= FindResourceW( hInstance
, lpTemplateName
, (LPCWSTR
)RT_DIALOG
))) return 0;
1443 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1444 return CreateDialogIndirectParamW( hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
);
1460 BOOL result
= FALSE
;
1461 DIALOGINFO
* dlgInfo
;
1463 /* if there's no dialog info property then call default windows proc?? */
1464 if (!(dlgInfo
= GETDLGINFO(hDlg
)))
1465 return DefWindowProcA( hDlg
, Msg
, wParam
, lParam
);
1467 SetWindowLongPtrW( hDlg
, DWLP_MSGRESULT
, 0 );
1469 if ((dlgproc
= (WNDPROC
)GetWindowLongPtrW( hDlg
, DWLP_DLGPROC
)))
1471 /* Call dialog procedure */
1472 result
= CallWindowProcA( dlgproc
, hDlg
, Msg
, wParam
, lParam
);
1475 if (!result
&& IsWindow(hDlg
))
1477 /* callback didn't process this message */
1491 case WM_ENTERMENULOOP
:
1492 case WM_LBUTTONDOWN
:
1493 case WM_NCLBUTTONDOWN
:
1494 return DEFDLG_Proc( hDlg
, Msg
, wParam
, lParam
, dlgInfo
);
1497 case WM_COMPAREITEM
:
1502 return DefWindowProcA( hDlg
, Msg
, wParam
, lParam
);
1505 return DEFDLG_Epilog(hDlg
, Msg
, result
);
1521 BOOL result
= FALSE
;
1522 DIALOGINFO
* dlgInfo
;
1524 /* if there's no dialog info property then call default windows proc?? */
1525 if (!(dlgInfo
= GETDLGINFO(hDlg
)))
1526 return DefWindowProcW( hDlg
, Msg
, wParam
, lParam
);
1528 SetWindowLongPtrW( hDlg
, DWLP_MSGRESULT
, 0 );
1530 if ((dlgproc
= (WNDPROC
)GetWindowLongPtrW( hDlg
, DWLP_DLGPROC
)))
1532 /* Call dialog procedure */
1533 result
= CallWindowProcW( dlgproc
, hDlg
, Msg
, wParam
, lParam
);
1536 if (!result
&& IsWindow(hDlg
))
1538 /* callback didn't process this message */
1552 case WM_ENTERMENULOOP
:
1553 case WM_LBUTTONDOWN
:
1554 case WM_NCLBUTTONDOWN
:
1555 return DEFDLG_Proc( hDlg
, Msg
, wParam
, lParam
, dlgInfo
);
1558 case WM_COMPAREITEM
:
1563 return DefWindowProcW( hDlg
, Msg
, wParam
, lParam
);
1566 return DEFDLG_Epilog(hDlg
, Msg
, result
);
1575 DialogBoxIndirectParamAorW(
1576 HINSTANCE hInstance
,
1577 LPCDLGTEMPLATE hDialogTemplate
,
1579 DLGPROC lpDialogFunc
,
1584 * This function might be obsolete since I don't think it is exported by NT
1585 * Also wine has one more parameter identifying weather it should call
1586 * the function with unicode or not
1588 HWND hWnd
= DIALOG_CreateIndirect( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, !Flags
, TRUE
);
1589 if (hWnd
) return DIALOG_DoDialogBox( hWnd
, hWndParent
);
1599 DialogBoxIndirectParamA(
1600 HINSTANCE hInstance
,
1601 LPCDLGTEMPLATE hDialogTemplate
,
1603 DLGPROC lpDialogFunc
,
1606 return DialogBoxIndirectParamAorW( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, 2);
1615 DialogBoxIndirectParamW(
1616 HINSTANCE hInstance
,
1617 LPCDLGTEMPLATE hDialogTemplate
,
1619 DLGPROC lpDialogFunc
,
1622 return DialogBoxIndirectParamAorW( hInstance
, hDialogTemplate
, hWndParent
, lpDialogFunc
, dwInitParam
, 0);
1632 HINSTANCE hInstance
,
1633 LPCSTR lpTemplateName
,
1635 DLGPROC lpDialogFunc
,
1642 if (!(hrsrc
= FindResourceA( hInstance
, lpTemplateName
, (LPCSTR
)RT_DIALOG
))) return 0;
1643 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1644 hwnd
= DIALOG_CreateIndirect(hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
, FALSE
, TRUE
);
1645 if (hwnd
) return DIALOG_DoDialogBox(hwnd
, hWndParent
);
1656 HINSTANCE hInstance
,
1657 LPCWSTR lpTemplateName
,
1659 DLGPROC lpDialogFunc
,
1666 if (!(hrsrc
= FindResourceW( hInstance
, lpTemplateName
, (LPCWSTR
)RT_DIALOG
))) return 0;
1667 if (!(ptr
= (LPCDLGTEMPLATE
)LoadResource(hInstance
, hrsrc
))) return 0;
1668 hwnd
= DIALOG_CreateIndirect(hInstance
, ptr
, hWndParent
, lpDialogFunc
, dwInitParam
, TRUE
, TRUE
);
1669 if (hwnd
) return DIALOG_DoDialogBox(hwnd
, hWndParent
);
1686 return DIALOG_DlgDirListA( hDlg
, lpPathSpec
, nIDListBox
, nIDStaticPath
, uFileType
, FALSE
);
1695 DlgDirListComboBoxA(
1702 return DIALOG_DlgDirListA( hDlg
, lpPathSpec
, nIDComboBox
, nIDStaticPath
, uFiletype
, TRUE
);
1711 DlgDirListComboBoxW(
1718 return DIALOG_DlgDirListW( hDlg
, lpPathSpec
, nIDComboBox
, nIDStaticPath
, uFiletype
, TRUE
);
1734 return DIALOG_DlgDirListW( hDlg
, lpPathSpec
, nIDListBox
, nIDStaticPath
, uFileType
, FALSE
);
1743 DlgDirSelectComboBoxExA(
1749 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDComboBox
, FALSE
, TRUE
);
1758 DlgDirSelectComboBoxExW(
1764 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDComboBox
, TRUE
, TRUE
);
1779 return DIALOG_DlgDirSelect( hDlg
, (LPWSTR
)lpString
, nCount
, nIDListBox
, FALSE
, FALSE
);
1794 return DIALOG_DlgDirSelect( hDlg
, lpString
, nCount
, nIDListBox
, TRUE
, FALSE
);
1807 BOOL wasEnabled
= TRUE
;
1808 DIALOGINFO
* dlgInfo
;
1811 if (!(dlgInfo
= GETDLGINFO(hDlg
))) return FALSE
;
1813 dlgInfo
->idResult
= nResult
;
1814 dlgInfo
->flags
|= DF_END
;
1815 wasEnabled
= (dlgInfo
->flags
& DF_OWNERENABLED
);
1817 if (wasEnabled
&& (owner
= GetWindow( hDlg
, GW_OWNER
)))
1818 DIALOG_EnableOwner( owner
);
1820 /* Windows sets the focus to the dialog itself in EndDialog */
1822 if (IsChild(hDlg
, GetFocus()))
1825 /* Don't have to send a ShowWindow(SW_HIDE), just do
1826 SetWindowPos with SWP_HIDEWINDOW as done in Windows */
1828 SetWindowPos(hDlg
, NULL
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
1829 | SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_HIDEWINDOW
);
1831 if (hDlg
== GetActiveWindow()) WinPosActivateOtherWindow( hDlg
);
1833 /* unblock dialog loop */
1834 PostMessageA(hDlg
, WM_NULL
, 0, 0);
1844 GetDialogBaseUnits(VOID
)
1853 if ((hdc
= GetDC(0)))
1855 size
.cx
= GdiGetCharDimensions( hdc
, NULL
, &size
.cy
);
1856 if (size
.cx
) units
= MAKELONG( size
.cx
, size
.cy
);
1857 ReleaseDC( 0, hdc
);
1872 return GetWindowLongPtrW( hwndCtl
, GWLP_ID
);
1885 GETDLGITEMINFO info
;
1886 info
.nIDDlgItem
= nIDDlgItem
;
1888 if(hDlg
&& !EnumChildWindows(hDlg
, (WNDENUMPROC
)&GetDlgItemEnumProc
, (LPARAM
)&info
))
1889 return info
.control
;
1910 if (lpTranslated
) *lpTranslated
= FALSE
;
1911 if (!SendDlgItemMessageA(hDlg
, nIDDlgItem
, WM_GETTEXT
, sizeof(str
), (LPARAM
)str
))
1915 result
= strtol( str
, &endptr
, 10 );
1916 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
1919 if (((result
== 0) || (result
== 0xFFFFFFFF))/* && (errno == ERANGE) */)
1924 result
= strtoul( str
, &endptr
, 10 );
1925 if (!endptr
|| (endptr
== str
)) /* Conversion was unsuccessful */
1928 if ((result
== 0xFFFFFFFF)/* && (errno == ERANGE) */) return 0;
1930 if (lpTranslated
) *lpTranslated
= TRUE
;
1931 return (UINT
)result
;
1946 if (lpString
&& (lpString
> 0)) lpString
[0] = '\0';
1947 return (UINT
)SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1962 if (lpString
&& (lpString
> 0)) lpString
[0] = '\0';
1963 return (UINT
)SendDlgItemMessageW( hDlg
, nIDDlgItem
, WM_GETTEXT
, nMaxCount
, (LPARAM
)lpString
);
1971 GetNextDlgGroupItem(
1976 HWND hwnd
, hwndNext
, retvalue
, hwndLastGroup
= 0;
1978 BOOL fSkipping
=FALSE
;
1980 if (hDlg
== hCtl
) hCtl
= NULL
;
1981 if (!hCtl
&& bPrevious
) return 0;
1983 /* if the hwndCtrl is the child of the control in the hwndDlg,
1984 * then the hwndDlg has to be the parent of the hwndCtrl */
1988 if (!IsChild (hDlg
, hCtl
)) return 0;
1989 /* Make sure hwndCtrl is a top-level child */
1994 /* No ctrl specified -> start from the beginning */
1995 if (!(hCtl
= GetWindow( hDlg
, GW_CHILD
))) return 0;
1996 /* MSDN is wrong. fPrevious does not result in the last child */
1998 /* No ctrl specified -> start from the beginning */
1999 if (!(hCtl
= GetWindow( hDlg
, GW_CHILD
))) return 0;
2001 /* MSDN is wrong. fPrevious does not result in the last child */
2003 /* Maybe that first one is valid. If so then we don't want to skip it*/
2004 if ((GetWindowLongW( hCtl
, GWL_STYLE
) & (WS_VISIBLE
|WS_DISABLED
)) == WS_VISIBLE
)
2011 /* Always go forward around the group and list of controls; for the
2012 * previous control keep track; for the next break when you find one
2016 while (hwndNext
= GetWindow (hwnd
, GW_HWNDNEXT
),
2021 /* Climb out until there is a next sibling of the ancestor or we
2022 * reach the top (in which case we loop back to the start)
2024 if (hDlg
== GetParent (hwnd
))
2026 /* Wrap around to the beginning of the list, within the same
2027 * group. (Once only)
2029 if (fLooped
) goto end
;
2031 hwndNext
= GetWindow (hDlg
, GW_CHILD
);
2035 hwnd
= GetParent (hwnd
);
2036 hwndNext
= GetWindow (hwnd
, GW_HWNDNEXT
);
2041 /* Wander down the leading edge of controlparents */
2042 while ( (GetWindowLongW (hwnd
, GWL_EXSTYLE
) & WS_EX_CONTROLPARENT
) &&
2043 ((GetWindowLongW (hwnd
, GWL_STYLE
) & (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
) &&
2044 (hwndNext
= GetWindow (hwnd
, GW_CHILD
)))
2046 /* Question. If the control is a control parent but either has no
2047 * children or is not visible/enabled then if it has a WS_GROUP does
2048 * it count? For that matter does it count anyway?
2049 * I believe it doesn't count.
2052 if ((GetWindowLongW (hwnd
, GWL_STYLE
) & WS_GROUP
))
2054 hwndLastGroup
= hwnd
;
2057 /* Look for the beginning of the group */
2064 if (!fSkipping
) break;
2065 if (hwndLastGroup
== hwnd
) break;
2066 hwnd
= hwndLastGroup
;
2072 (GetWindowLongW (hwnd
, GWL_STYLE
) & (WS_VISIBLE
|WS_DISABLED
)) ==
2076 if (!bPrevious
) break;
2094 /* Undocumented but tested under Win2000 and WinME */
2095 if (hDlg
== hCtl
) hCtl
= NULL
;
2097 /* Contrary to MSDN documentation, tested under Win2000 and WinME
2098 * NB GetLastError returns whatever was set before the function was
2101 if (!hCtl
&& bPrevious
) return 0;
2103 return DIALOG_GetNextTabItem(hDlg
, hDlg
, hCtl
, bPrevious
);
2114 return IsDialogMessageW(hDlg
, lpMsg
);
2118 /***********************************************************************
2119 * DIALOG_FixOneChildOnChangeFocus
2121 * Callback helper for DIALOG_FixChildrenOnChangeFocus
2124 static BOOL CALLBACK
DIALOG_FixOneChildOnChangeFocus (HWND hwndChild
,
2127 /* If a default pushbutton then no longer default */
2128 if (DLGC_DEFPUSHBUTTON
& SendMessageW (hwndChild
, WM_GETDLGCODE
, 0, 0))
2129 SendMessageW (hwndChild
, BM_SETSTYLE
, BS_PUSHBUTTON
, TRUE
);
2133 /***********************************************************************
2134 * DIALOG_FixChildrenOnChangeFocus
2136 * Following the change of focus that occurs for example after handling
2137 * a WM_KEYDOWN VK_TAB in IsDialogMessage, some tidying of the dialog's
2138 * children may be required.
2140 static void DIALOG_FixChildrenOnChangeFocus (HWND hwndDlg
, HWND hwndNext
)
2142 INT dlgcode_next
= SendMessageW (hwndNext
, WM_GETDLGCODE
, 0, 0);
2143 /* INT dlgcode_dlg = SendMessageW (hwndDlg, WM_GETDLGCODE, 0, 0); */
2144 /* Windows does ask for this. I don't know why yet */
2146 EnumChildWindows (hwndDlg
, DIALOG_FixOneChildOnChangeFocus
, 0);
2148 /* If the button that is getting the focus WAS flagged as the default
2149 * pushbutton then ask the dialog what it thinks the default is and
2150 * set that in the default style.
2152 if (dlgcode_next
& DLGC_DEFPUSHBUTTON
)
2154 DWORD def_id
= SendMessageW (hwndDlg
, DM_GETDEFID
, 0, 0);
2155 if (HIWORD(def_id
) == DC_HASDEFID
)
2158 def_id
= LOWORD(def_id
);
2159 hwndDef
= GetDlgItem (hwndDlg
, def_id
);
2162 INT dlgcode_def
= SendMessageW (hwndDef
, WM_GETDLGCODE
, 0, 0);
2163 /* I know that if it is a button then it should already be a
2164 * UNDEFPUSHBUTTON, since we have just told the buttons to
2165 * change style. But maybe they ignored our request
2167 if ((dlgcode_def
& DLGC_BUTTON
) &&
2168 (dlgcode_def
& DLGC_UNDEFPUSHBUTTON
))
2170 SendMessageW (hwndDef
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
2175 else if ((dlgcode_next
& DLGC_BUTTON
) && (dlgcode_next
& DLGC_UNDEFPUSHBUTTON
))
2177 SendMessageW (hwndNext
, BM_SETSTYLE
, BS_DEFPUSHBUTTON
, TRUE
);
2178 /* I wonder why it doesn't send a DM_SETDEFID */
2194 if (CallMsgFilterW( lpMsg
, MSGF_DIALOGBOX
)) return TRUE
;
2196 if ((hDlg
!= lpMsg
->hwnd
) && !IsChild( hDlg
, lpMsg
->hwnd
)) return FALSE
;
2198 if (hDlg
== GetDesktopWindow()) return FALSE
;
2200 hDlg
= DIALOG_FindMsgDestination(hDlg
);
2202 switch(lpMsg
->message
)
2205 dlgCode
= SendMessageW( lpMsg
->hwnd
, WM_GETDLGCODE
, lpMsg
->wParam
, (LPARAM
)lpMsg
);
2206 if (dlgCode
& DLGC_WANTMESSAGE
) break;
2208 switch(lpMsg
->wParam
)
2211 if (!(dlgCode
& DLGC_WANTTAB
))
2213 SendMessageW(hDlg
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_CLEAR
, UISF_HIDEFOCUS
), 0);
2215 /* I am not sure under which circumstances the TAB is handled
2216 * each way. All I do know is that it does not always simply
2217 * send WM_NEXTDLGCTL. (Personally I have never yet seen it
2218 * do so but I presume someone has)
2220 if (GETDLGINFO(hDlg
))
2221 SendMessageW( hDlg
, WM_NEXTDLGCTL
, (GetKeyState(VK_SHIFT
) & 0x8000), 0 );
2224 /* It would appear that GetNextDlgTabItem can handle being
2225 * passed hwndDlg rather than NULL but that is undocumented
2226 * so let's do it properly
2228 HWND hwndFocus
= GetFocus();
2229 HWND hwndNext
= GetNextDlgTabItem (hDlg
,
2230 hwndFocus
== hDlg
? NULL
: hwndFocus
,
2231 GetKeyState (VK_SHIFT
) & 0x8000);
2234 dlgCode
= SendMessageW (hwndNext
, WM_GETDLGCODE
,
2235 lpMsg
->wParam
, (LPARAM
)lpMsg
);
2236 if (dlgCode
& DLGC_HASSETSEL
)
2238 INT maxlen
= 1 + SendMessageW (hwndNext
, WM_GETTEXTLENGTH
, 0, 0);
2239 WCHAR
*buffer
= HeapAlloc (GetProcessHeap(), 0, maxlen
* sizeof(WCHAR
));
2243 SendMessageW (hwndNext
, WM_GETTEXT
, maxlen
, (LPARAM
) buffer
);
2244 length
= wcslen (buffer
);
2245 HeapFree (GetProcessHeap(), 0, buffer
);
2246 SendMessageW (hwndNext
, EM_SETSEL
, 0, length
);
2249 SetFocus (hwndNext
);
2250 DIALOG_FixChildrenOnChangeFocus (hDlg
, hwndNext
);
2263 if (!(dlgCode
& DLGC_WANTARROWS
))
2265 BOOL fPrevious
= (lpMsg
->wParam
== VK_LEFT
|| lpMsg
->wParam
== VK_UP
);
2266 HWND hwndNext
= GetNextDlgGroupItem (hDlg
, GetFocus(), fPrevious
);
2267 SendMessageW( hDlg
, WM_NEXTDLGCTL
, (WPARAM
)hwndNext
, 1 );
2274 SendMessageW( hDlg
, WM_COMMAND
, IDCANCEL
, (LPARAM
)GetDlgItem( hDlg
, IDCANCEL
) );
2281 if ((GetFocus() == lpMsg
->hwnd
) &&
2282 (SendMessageW (lpMsg
->hwnd
, WM_GETDLGCODE
, 0, 0) & DLGC_DEFPUSHBUTTON
))
2284 SendMessageW (hDlg
, WM_COMMAND
, MAKEWPARAM (GetDlgCtrlID(lpMsg
->hwnd
),BN_CLICKED
), (LPARAM
)lpMsg
->hwnd
);
2286 else if (DC_HASDEFID
== HIWORD(dw
= SendMessageW (hDlg
, DM_GETDEFID
, 0, 0)))
2288 SendMessageW( hDlg
, WM_COMMAND
, MAKEWPARAM( LOWORD(dw
), BN_CLICKED
),
2289 (LPARAM
)GetDlgItem(hDlg
, LOWORD(dw
)));
2293 SendMessageW( hDlg
, WM_COMMAND
, IDOK
, (LPARAM
)GetDlgItem( hDlg
, IDOK
) );
2302 dlgCode
= SendMessageW( lpMsg
->hwnd
, WM_GETDLGCODE
, lpMsg
->wParam
, (LPARAM
)lpMsg
);
2303 if (dlgCode
& (DLGC_WANTCHARS
|DLGC_WANTMESSAGE
)) break;
2304 if (lpMsg
->wParam
== '\t' && (dlgCode
& DLGC_WANTTAB
)) break;
2308 if (DIALOG_IsAccelerator( lpMsg
->hwnd
, hDlg
, lpMsg
->wParam
))
2310 /* don't translate or dispatch */
2316 SendMessageW(hDlg
, WM_CHANGEUISTATE
, MAKEWPARAM(UIS_CLEAR
, UISF_HIDEFOCUS
), 0);
2320 TranslateMessage( lpMsg
);
2321 DispatchMessageW( lpMsg
);
2335 return (UINT
)SendDlgItemMessageW( hDlg
, nIDButton
, BM_GETCHECK
, 0, 0 );
2348 DIALOGINFO
* dlgInfo
;
2349 if (!(dlgInfo
= GETDLGINFO(hDlg
))) return FALSE
;
2350 lpRect
->left
= MulDiv(lpRect
->left
, dlgInfo
->xBaseUnit
, 4);
2351 lpRect
->right
= MulDiv(lpRect
->right
, dlgInfo
->xBaseUnit
, 4);
2352 lpRect
->top
= MulDiv(lpRect
->top
, dlgInfo
->yBaseUnit
, 8);
2353 lpRect
->bottom
= MulDiv(lpRect
->bottom
, dlgInfo
->yBaseUnit
, 8);
2363 SendDlgItemMessageA(
2370 HWND hwndCtrl
= GetDlgItem( hDlg
, nIDDlgItem
);
2371 if (hwndCtrl
) return SendMessageA( hwndCtrl
, Msg
, wParam
, lParam
);
2381 SendDlgItemMessageW(
2388 HWND hwndCtrl
= GetDlgItem( hDlg
, nIDDlgItem
);
2389 if (hwndCtrl
) return SendMessageW( hwndCtrl
, Msg
, wParam
, lParam
);
2407 if (bSigned
) sprintf( str
, "%d", (INT
)uValue
);
2408 else sprintf( str
, "%u", uValue
);
2409 SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)str
);
2424 return SendDlgItemMessageA( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2438 return SendDlgItemMessageW( hDlg
, nIDDlgItem
, WM_SETTEXT
, 0, (LPARAM
)lpString
);
2452 SendDlgItemMessageW( hDlg
, nIDButton
, BM_SETCHECK
, uCheck
, 0 );
2456 static BOOL CALLBACK
CheckRB(HWND hwnd
, LPARAM lParam
)
2458 LONG lChildID
= GetWindowLongPtrW(hwnd
, GWLP_ID
);
2459 RADIOGROUP
*lpRadioGroup
= (RADIOGROUP
*)lParam
;
2461 if((lChildID
>= lpRadioGroup
->firstID
) &&
2462 (lChildID
<= lpRadioGroup
->lastID
))
2464 if (lChildID
== lpRadioGroup
->checkID
)
2466 SendMessageW(hwnd
, BM_SETCHECK
, BST_CHECKED
, 0);
2470 SendMessageW(hwnd
, BM_SETCHECK
, BST_UNCHECKED
, 0);
2488 RADIOGROUP radioGroup
;
2490 radioGroup
.firstID
= nIDFirstButton
;
2491 radioGroup
.lastID
= nIDLastButton
;
2492 radioGroup
.checkID
= nIDCheckButton
;
2494 return EnumChildWindows(hDlg
, CheckRB
, (LPARAM
)&radioGroup
);