Commit 87115b23 authored by Alexandre Julliard's avatar Alexandre Julliard

WM_NEXTDLGCTL should not change the default button ID (based on a

patch by Krishna Murthy).
parent 8024b5ee
......@@ -588,7 +588,7 @@ static void WM_NEXTDLGCTLTest(void)
* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL"
*/
dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0);
todo_wine ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n");
ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n");
/*
* Check whether the style of the button which got the focus, changed to BS_DEFPUSHBUTTON and
......@@ -621,7 +621,7 @@ static void WM_NEXTDLGCTLTest(void)
*/
if ( IDCANCEL == (LOWORD(dwVal)) )
{
todo_wine ok ( ((GetWindowLong( g_hwndTestDlgBut2, GWL_STYLE)) & BS_DEFPUSHBUTTON),
ok ( ((GetWindowLong( g_hwndTestDlgBut2, GWL_STYLE)) & BS_DEFPUSHBUTTON),
"Button2 style not set to BS_DEFPUSHBUTTON\n" );
ok ( !((GetWindowLong( g_hwndTestDlgBut1, GWL_STYLE)) & BS_DEFPUSHBUTTON),
......@@ -638,7 +638,7 @@ static void WM_NEXTDLGCTLTest(void)
* Check whether the default button ID got changed by sending message "WM_NEXTDLGCTL"
*/
dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0);
todo_wine ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n");
ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n");
}
}
......
......@@ -127,14 +127,15 @@ static HWND DEFDLG_FindDefButton( HWND hwndDlg )
/***********************************************************************
* DEFDLG_SetDefButton
* DEFDLG_SetDefId
*
* Set the new default button to be hwndNew.
* Set the default button id.
*/
static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo, WPARAM wParam )
static BOOL DEFDLG_SetDefId( HWND hwndDlg, DIALOGINFO *dlgInfo, WPARAM wParam)
{
DWORD dlgcode=0; /* initialize just to avoid a warning */
HWND hwndNew = GetDlgItem(hwndDlg, wParam);
HWND hwndOld, hwndNew = GetDlgItem(hwndDlg, wParam);
INT old_id = dlgInfo->idResult;
dlgInfo->idResult = wParam;
if (hwndNew &&
......@@ -142,15 +143,54 @@ static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo, WPARAM wPara
& (DLGC_UNDEFPUSHBUTTON | DLGC_BUTTON)))
return FALSE; /* Destination is not a push button */
if (dlgInfo->idResult) /* There's already a default pushbutton */
/* Make sure the old default control is a valid push button ID */
hwndOld = GetDlgItem( hwndDlg, old_id );
if (!hwndOld || !(SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
hwndOld = DEFDLG_FindDefButton( hwndDlg );
if (hwndOld && hwndOld != hwndNew)
SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE );
if (hwndNew)
{
HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->idResult );
if (hwndOld && (SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE );
if(dlgcode & DLGC_UNDEFPUSHBUTTON)
SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
}
return TRUE;
}
/***********************************************************************
* DEFDLG_SetDefButton
*
* Set the new default button to be hwndNew.
*/
static BOOL DEFDLG_SetDefButton( HWND hwndDlg, DIALOGINFO *dlgInfo, HWND hwndNew )
{
DWORD dlgcode=0; /* initialize just to avoid a warning */
HWND hwndOld = GetDlgItem( hwndDlg, dlgInfo->idResult );
if (hwndNew &&
!((dlgcode=SendMessageW(hwndNew, WM_GETDLGCODE, 0, 0 ))
& (DLGC_UNDEFPUSHBUTTON | DLGC_DEFPUSHBUTTON)))
{
/**
* Need to draw only default push button rectangle.
* Since the next control is not a push button, need to draw the push
* button rectangle for the default control.
*/
hwndNew = hwndOld;
dlgcode = SendMessageW(hwndNew, WM_GETDLGCODE, 0, 0 );
}
/* Make sure the old default control is a valid push button ID */
if (!hwndOld || !(SendMessageA( hwndOld, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON))
hwndOld = DEFDLG_FindDefButton( hwndDlg );
if (hwndOld && hwndOld != hwndNew)
SendMessageA( hwndOld, BM_SETSTYLE, BS_PUSHBUTTON, TRUE );
if (hwndNew)
{
if(dlgcode==DLGC_UNDEFPUSHBUTTON)
if(dlgcode & DLGC_UNDEFPUSHBUTTON)
SendMessageA( hwndNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
}
return TRUE;
......@@ -214,7 +254,7 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
case DM_SETDEFID:
if (dlgInfo && !(dlgInfo->flags & DF_END))
DEFDLG_SetDefButton( hwnd, dlgInfo, wParam );
DEFDLG_SetDefId( hwnd, dlgInfo, wParam );
return 1;
case DM_GETDEFID:
......@@ -235,7 +275,7 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
if (!lParam)
hwndDest = GetNextDlgTabItem(hwnd, GetFocus(), wParam);
if (hwndDest) DEFDLG_SetFocus( hwnd, hwndDest );
DEFDLG_SetDefButton( hwnd, dlgInfo, GetDlgCtrlID(hwndDest) );
DEFDLG_SetDefButton( hwnd, dlgInfo, hwndDest );
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment