Commit 21898b2f authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

comctl32: Remove property sheet page that can't be initialized.

parent a64b7918
......@@ -171,6 +171,7 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, const PropSheetInfo* psInfo);
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);
static INT_PTR CALLBACK
PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
......@@ -1474,6 +1475,9 @@ static BOOL PROPSHEET_CreatePage(HWND hwndParent,
/* Free a no more needed copy */
Free(pTemplateCopy);
if(!hwndPage)
return FALSE;
psInfo->proppage[index].hwndPage = hwndPage;
/* Subclass exterior wizard pages */
......@@ -2025,7 +2029,14 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
psn.lParam = 0;
if (!psInfo->proppage[index].hwndPage) {
PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage);
if(!PROPSHEET_CreatePage(hwndDlg, index, psInfo, ppshpage)) {
PROPSHEET_RemovePage(hwndDlg, index, NULL);
if(index >= psInfo->nPages)
index--;
if(index < 0)
return FALSE;
continue;
}
}
/* Resize the property sheet page to the fit in the Tab control
......@@ -2273,7 +2284,8 @@ static BOOL PROPSHEET_AddPage(HWND hwndDlg,
if (ppsp->dwFlags & PSP_PREMATURE)
{
/* Create the page but don't show it */
PROPSHEET_CreatePage(hwndDlg, psInfo->nPages, psInfo, ppsp);
if(!PROPSHEET_CreatePage(hwndDlg, psInfo->nPages, psInfo, ppsp))
return FALSE;
}
/*
......
......@@ -750,7 +750,7 @@ static void test_messages(void)
static void test_PSM_ADDPAGE(void)
{
HPROPSHEETPAGE hpsp[3];
HPROPSHEETPAGE hpsp[5];
PROPSHEETPAGEA psp;
PROPSHEETHEADERA psh;
HWND hdlg, tab;
......@@ -771,6 +771,12 @@ static void test_PSM_ADDPAGE(void)
hpsp[1] = CreatePropertySheetPageA(&psp);
hpsp[2] = CreatePropertySheetPageA(&psp);
U(psp).pszTemplate = MAKEINTRESOURCE(IDD_PROP_PAGE_ERROR);
hpsp[3] = CreatePropertySheetPageA(&psp);
psp.dwFlags = PSP_PREMATURE;
hpsp[4] = CreatePropertySheetPageA(&psp);
memset(&psh, 0, sizeof(psh));
psh.dwSize = PROPSHEETHEADERA_V1_SIZE;
psh.dwFlags = PSH_MODELESS;
......@@ -807,6 +813,27 @@ if (0)
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
ok(r == 3, "got %d\n", r);
/* add property sheet page that can't be created */
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[3]);
ok(ret == TRUE, "got %d\n", ret);
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
ok(r == 4, "got %d\n", r);
/* select page that can't be created */
ret = SendMessageA(hdlg, PSM_SETCURSEL, 3, 0);
ok(ret == TRUE, "got %d\n", ret);
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
ok(r == 3, "got %d\n", r);
/* test PSP_PREMATURE flag with incorrect property sheet page */
ret = SendMessageA(hdlg, PSM_ADDPAGE, 0, (LPARAM)hpsp[4]);
ok(ret == FALSE, "got %d\n", ret);
r = SendMessageA(tab, TCM_GETITEMCOUNT, 0, 0);
ok(r == 3, "got %d\n", r);
DestroyWindow(hdlg);
}
......
......@@ -38,6 +38,7 @@
#define IDD_PROP_PAGE_WITH_CUSTOM_DEFAULT_BUTTON 34
#define IDD_PROP_PAGE_MESSAGE_TEST 35
#define IDD_PROP_PAGE_ERROR 36
#define IDC_PS_EDIT1 1000
#define IDC_PS_EDIT2 1001
......
......@@ -71,6 +71,13 @@ BEGIN
LTEXT "Some Text",-1,115,1,195,24
END
IDD_PROP_PAGE_ERROR DIALOG 0, 0, 100, 100
STYLE WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS | WS_VISIBLE
CLASS "Non-existing class"
FONT 8, "MS Shell Dlg"
{
}
STRINGTABLE
{
IDS_TBADD1 "abc"
......
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