Commit 433df0d5 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

comctl32: Enable the appropriate wizard buttons before sending DM_SETDEFID.

parent 04305134
......@@ -2430,15 +2430,16 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
BOOL enable_finish = ((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH);
TRACE("%d\n", dwFlags);
EnableWindow(hwndBack, FALSE);
EnableWindow(hwndNext, FALSE);
EnableWindow(hwndFinish, FALSE);
EnableWindow(hwndBack, dwFlags & PSWIZB_BACK);
EnableWindow(hwndNext, dwFlags & PSWIZB_NEXT);
EnableWindow(hwndFinish, enable_finish);
/* set the default pushbutton to an enabled button */
if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH))
if (enable_finish)
SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
else if (dwFlags & PSWIZB_NEXT)
SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
......@@ -2447,13 +2448,6 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
else
SendMessageW(hwndDlg, DM_SETDEFID, IDCANCEL, 0);
if (dwFlags & PSWIZB_BACK)
EnableWindow(hwndBack, TRUE);
if (dwFlags & PSWIZB_NEXT)
EnableWindow(hwndNext, TRUE);
if (!psInfo->hasFinish)
{
if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH))
......@@ -2463,9 +2457,6 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
/* Show the Finish button */
ShowWindow(hwndFinish, SW_SHOW);
if (!(dwFlags & PSWIZB_DISABLEDFINISH))
EnableWindow(hwndFinish, TRUE);
}
else
{
......@@ -2475,8 +2466,6 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
ShowWindow(hwndNext, SW_SHOW);
}
}
else if (!(dwFlags & PSWIZB_DISABLEDFINISH))
EnableWindow(hwndFinish, TRUE);
}
/******************************************************************************
......
......@@ -279,6 +279,37 @@ static INT_PTR CALLBACK nav_page_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
return FALSE;
}
static WNDPROC old_nav_dialog_proc;
static LRESULT CALLBACK new_nav_dialog_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
switch (msg)
{
case DM_SETDEFID:
ok( IsWindowEnabled( GetDlgItem(hwnd, wp) ), "button is not enabled\n" );
break;
}
return CallWindowProcW( old_nav_dialog_proc, hwnd, msg, wp, lp );
}
static LRESULT CALLBACK hook_proc( int code, WPARAM wp, LPARAM lp )
{
static BOOL done;
if (code == HCBT_CREATEWND)
{
CBT_CREATEWNDW *c = (CBT_CREATEWNDW *)lp;
/* The first dialog created will be the parent dialog */
if (!done && c->lpcs->lpszClass == MAKEINTRESOURCEW(WC_DIALOG))
{
old_nav_dialog_proc = (WNDPROC)SetWindowLongPtrW( (HWND)wp, GWLP_WNDPROC, (LONG_PTR)new_nav_dialog_proc );
done = TRUE;
}
}
return CallNextHookEx( NULL, code, wp, lp );
}
static void test_wiznavigation(void)
{
HPROPSHEETPAGE hpsp[4];
......@@ -291,6 +322,10 @@ static void test_wiznavigation(void)
BOOL hwndtoindex_supported = TRUE;
const INT nextID = 12324;
const INT backID = 12323;
HHOOK hook;
/* set up a hook proc in order to subclass the main dialog early on */
hook = SetWindowsHookExW( WH_CBT, hook_proc, NULL, GetCurrentThreadId() );
/* create the property sheet pages */
memset(psp, 0, sizeof(PROPSHEETPAGEA) * 4);
......@@ -400,6 +435,7 @@ static void test_wiznavigation(void)
ok(defidres == MAKELRESULT(nextID, DC_HASDEFID), "Expected default button ID to be %d, is %d\n", nextID, LOWORD(defidres));
DestroyWindow(hdlg);
UnhookWindowsHookEx( hook );
}
static void test_buttons(void)
......
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