From 379d492b12b25e16b7c83872658042bf99d30c55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ri=C4=8Dardas=20Barkauskas?= Date: Fri, 21 Dec 2012 19:06:45 +0200 Subject: [PATCH] comctl32: Use index value if property sheet page isn't found. --- dlls/comctl32/propsheet.c | 40 ++++++++++++++-------------------------- dlls/comctl32/tests/propsheet.c | 2 +- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c index b73c448f80d..c3db7e355f0 100644 --- a/dlls/comctl32/propsheet.c +++ b/dlls/comctl32/propsheet.c @@ -168,7 +168,7 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg, int index, int skipdir, HPROPSHEETPAGE hpage); -static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, const PropSheetInfo* psInfo); +static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, const PropSheetInfo* psInfo, int original_index); static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg, const PropSheetInfo* psInfo); static BOOL PROPSHEET_DoCommand(HWND hwnd, WORD wID); static BOOL PROPSHEET_RemovePage(HWND hwndDlg, int index, HPROPSHEETPAGE hpage); @@ -1998,9 +1998,8 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg, HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL); TRACE("index %d, skipdir %d, hpage %p\n", index, skipdir, hpage); - /* hpage takes precedence over index */ - if (hpage != NULL) - index = PROPSHEET_GetPageIndex(hpage, psInfo); + + index = PROPSHEET_GetPageIndex(hpage, psInfo, index); if (index < 0 || index >= psInfo->nPages) { @@ -2331,13 +2330,8 @@ static BOOL PROPSHEET_RemovePage(HWND hwndDlg, if (!psInfo) { return FALSE; } - /* - * hpage takes precedence over index. - */ - if (hpage != 0) - { - index = PROPSHEET_GetPageIndex(hpage, psInfo); - } + + index = PROPSHEET_GetPageIndex(hpage, psInfo, index); /* Make sure that index is within range */ if (index < 0 || index >= psInfo->nPages) @@ -2652,26 +2646,20 @@ static BOOL PROPSHEET_RecalcPageSizes(HWND hwndDlg) * PROPSHEET_GetPageIndex * * Given a HPROPSHEETPAGE, returns the index of the corresponding page from - * the array of PropPageInfo. + * the array of PropPageInfo. If page is not found original index is used + * (page takes precedence over index). */ -static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, const PropSheetInfo* psInfo) +static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE page, const PropSheetInfo* psInfo, int original_index) { - BOOL found = FALSE; - int index = 0; + int index; - TRACE("hpage %p\n", hpage); - while ((index < psInfo->nPages) && (found == FALSE)) - { - if (psInfo->proppage[index].hpage == hpage) - found = TRUE; - else - index++; - } + TRACE("page %p index %d\n", page, original_index); - if (found == FALSE) - index = -1; + for (index = 0; index < psInfo->nPages; index++) + if (psInfo->proppage[index].hpage == page) + return index; - return index; + return original_index; } /****************************************************************************** diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c index 992b60fb34e..f235791929c 100644 --- a/dlls/comctl32/tests/propsheet.c +++ b/dlls/comctl32/tests/propsheet.c @@ -821,7 +821,7 @@ if (0) ok(r == 4, "got %d\n", r); /* select page that can't be created */ - ret = SendMessageA(hdlg, PSM_SETCURSEL, 3, 0); + ret = SendMessageA(hdlg, PSM_SETCURSEL, 3, 1); ok(ret == TRUE, "got %d\n", ret); r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0); -- 2.11.4.GIT