From 2f8e5da90f819b0fba565b96ac06263463d06296 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Mon, 31 Aug 2009 14:09:00 +0200 Subject: [PATCH] comctl32/propsheet: Update position of hidden buttons too. --- dlls/comctl32/propsheet.c | 31 ++++++++------------- dlls/comctl32/tests/propsheet.c | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 20 deletions(-) diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index e7674448889..4759d4c4d8e 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -904,7 +904,7 @@ static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, const PropSheetInfo* psInfo */ hwndButton = GetDlgItem(hwndParent, IDCANCEL); - x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1)); + x += padding.x + buttonWidth; SetWindowPos(hwndButton, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); @@ -914,34 +914,25 @@ static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, const PropSheetInfo* psInfo */ hwndButton = GetDlgItem(hwndParent, IDC_APPLY_BUTTON); - if (psInfo->hasApply) - { - if (psInfo->hasHelp) - x = rcSheet.right - ((padding.x + buttonWidth) * 2); - else - x = rcSheet.right - (padding.x + buttonWidth); - - SetWindowPos(hwndButton, 0, x, y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - - EnableWindow(hwndButton, FALSE); - } + if(psInfo->hasApply) + x += padding.x + buttonWidth; else ShowWindow(hwndButton, SW_HIDE); + SetWindowPos(hwndButton, 0, x, y, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); + EnableWindow(hwndButton, FALSE); + /* * Position Help button. */ hwndButton = GetDlgItem(hwndParent, IDHELP); - if (psInfo->hasHelp) - { - x = rcSheet.right - (padding.x + buttonWidth); + x += padding.x + buttonWidth; + SetWindowPos(hwndButton, 0, x, y, 0, 0, + SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - SetWindowPos(hwndButton, 0, x, y, 0, 0, - SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - } - else + if(!psInfo->hasHelp) ShowWindow(hwndButton, SW_HIDE); return TRUE; diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c index cf5c2017c70..0eebe3350ce 100644 --- a/dlls/comctl32/tests/propsheet.c +++ b/dlls/comctl32/tests/propsheet.c @@ -1,6 +1,7 @@ /* Unit test suite for property sheet control. * * Copyright 2006 Huw Davies + * Copyright 2009 Jan de Mooij * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,6 +29,8 @@ static HWND parent; static LONG active_page = -1; +#define IDC_APPLY_BUTTON 12321 + static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam) { switch(msg) @@ -341,6 +344,64 @@ static void test_wiznavigation(void) DestroyWindow(hdlg); } +static void test_buttons(void) +{ + HPROPSHEETPAGE hpsp[1]; + PROPSHEETPAGEA psp; + PROPSHEETHEADERA psh; + HWND hdlg; + HWND button; + RECT rc; + int prevRight, top; + + memset(&psp, 0, sizeof(psp)); + psp.dwSize = sizeof(psp); + psp.dwFlags = 0; + psp.hInstance = GetModuleHandleW(NULL); + U(psp).pszTemplate = "prop_page1"; + U2(psp).pszIcon = NULL; + psp.pfnDlgProc = page_dlg_proc; + psp.lParam = 0; + + hpsp[0] = CreatePropertySheetPageA(&psp); + + memset(&psh, 0, sizeof(psh)); + psh.dwSize = sizeof(psh); + psh.dwFlags = PSH_MODELESS | PSH_USECALLBACK; + psh.pszCaption = "test caption"; + psh.nPages = 1; + psh.hwndParent = GetDesktopWindow(); + U3(psh).phpage = hpsp; + psh.pfnCallback = sheet_callback; + + hdlg = (HWND)PropertySheetA(&psh); + + /* OK button */ + button = GetDlgItem(hdlg, IDOK); + GetWindowRect(button, &rc); + prevRight = rc.right; + top = rc.top; + + /* Cancel button */ + button = GetDlgItem(hdlg, IDCANCEL); + GetWindowRect(button, &rc); + ok(rc.top == top, "Cancel button should have same top as OK button\n"); + ok(rc.left > prevRight, "Cancel button should be to the right of OK button\n"); + prevRight = rc.right; + + button = GetDlgItem(hdlg, IDC_APPLY_BUTTON); + GetWindowRect(button, &rc); + ok(rc.top == top, "Apply button should have same top as OK button\n"); + ok(rc.left > prevRight, "Apply button should be to the right of Cancel button\n"); + prevRight = rc.right; + + button = GetDlgItem(hdlg, IDHELP); + GetWindowRect(button, &rc); + ok(rc.top == top, "Help button should have same top as OK button\n"); + ok(rc.left > prevRight, "Help button should be to the right of Apply button\n"); + + DestroyWindow(hdlg); +} START_TEST(propsheet) { @@ -348,4 +409,5 @@ START_TEST(propsheet) test_nopage(); test_disableowner(); test_wiznavigation(); + test_buttons(); } -- 2.11.4.GIT