comctl32/propsheet: Implement PSPCB_ADDREF/PSPCB_RELEASE notifications.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-03-01 22:47:21 +03:00 committed by Alexandre Julliard
parent a3aa217f03
commit 429705eaf3
2 changed files with 35 additions and 10 deletions

View File

@ -2962,8 +2962,18 @@ HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
if (lpPropSheetPage->dwSize < PROPSHEETPAGEA_V1_SIZE) if (lpPropSheetPage->dwSize < PROPSHEETPAGEA_V1_SIZE)
return NULL; return NULL;
ppsp = Alloc(sizeof(PROPSHEETPAGEW)); /* original data is used for callback notifications */
if ((lpPropSheetPage->dwFlags & PSP_USECALLBACK) && lpPropSheetPage->pfnCallback)
{
ppsp = Alloc(2 * sizeof(*ppsp));
memcpy(ppsp, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEA))); memcpy(ppsp, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEA)));
memcpy(ppsp + 1, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEA)));
}
else
{
ppsp = Alloc(sizeof(*ppsp));
memcpy(ppsp, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEA)));
}
ppsp->dwFlags &= ~PSP_INTERNAL_UNICODE; ppsp->dwFlags &= ~PSP_INTERNAL_UNICODE;
@ -3017,6 +3027,9 @@ HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
else else
ppsp->pszHeaderSubTitle = NULL; ppsp->pszHeaderSubTitle = NULL;
if ((ppsp->dwFlags & PSP_USECALLBACK) && ppsp->dwSize > PROPSHEETPAGEA_V1_SIZE && ppsp->pfnCallback)
ppsp->pfnCallback(0, PSPCB_ADDREF, ppsp + 1);
return (HPROPSHEETPAGE)ppsp; return (HPROPSHEETPAGE)ppsp;
} }
@ -3032,8 +3045,18 @@ HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
if (lpPropSheetPage->dwSize < PROPSHEETPAGEW_V1_SIZE) if (lpPropSheetPage->dwSize < PROPSHEETPAGEW_V1_SIZE)
return NULL; return NULL;
ppsp = Alloc(sizeof(PROPSHEETPAGEW)); /* original data is used for callback notifications */
if ((lpPropSheetPage->dwFlags & PSP_USECALLBACK) && lpPropSheetPage->pfnCallback)
{
ppsp = Alloc(2 * sizeof(*ppsp));
memcpy(ppsp, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEW))); memcpy(ppsp, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEW)));
memcpy(ppsp + 1, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEW)));
}
else
{
ppsp = Alloc(sizeof(*ppsp));
memcpy(ppsp, lpPropSheetPage, min(lpPropSheetPage->dwSize, sizeof(PROPSHEETPAGEW)));
}
ppsp->dwFlags |= PSP_INTERNAL_UNICODE; ppsp->dwFlags |= PSP_INTERNAL_UNICODE;
@ -3067,6 +3090,9 @@ HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage
else else
ppsp->pszHeaderSubTitle = NULL; ppsp->pszHeaderSubTitle = NULL;
if ((ppsp->dwFlags & PSP_USECALLBACK) && ppsp->dwSize > PROPSHEETPAGEW_V1_SIZE && ppsp->pfnCallback)
ppsp->pfnCallback(0, PSPCB_ADDREF, ppsp + 1);
return (HPROPSHEETPAGE)ppsp; return (HPROPSHEETPAGE)ppsp;
} }
@ -3088,6 +3114,9 @@ BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
if (!psp) if (!psp)
return FALSE; return FALSE;
if ((psp->dwFlags & PSP_USECALLBACK) && psp->pfnCallback)
psp->pfnCallback(0, PSPCB_RELEASE, psp + 1);
if (!(psp->dwFlags & PSP_DLGINDIRECT) && !IS_INTRESOURCE( psp->u.pszTemplate )) if (!(psp->dwFlags & PSP_DLGINDIRECT) && !IS_INTRESOURCE( psp->u.pszTemplate ))
Free ((LPVOID)psp->u.pszTemplate); Free ((LPVOID)psp->u.pszTemplate);

View File

@ -1080,7 +1080,6 @@ static void test_CreatePropertySheetPage(void)
else else
{ {
ok(hpsp != NULL, "Failed to create a page, size %u\n", page.u.pageA.dwSize); ok(hpsp != NULL, "Failed to create a page, size %u\n", page.u.pageA.dwSize);
todo_wine_if(page.u.pageA.dwSize > PROPSHEETPAGEA_V1_SIZE)
ok(page.addref_called == (page.u.pageA.dwSize > PROPSHEETPAGEA_V1_SIZE) ? 1 : 0, "Expected ADDREF callback message\n"); ok(page.addref_called == (page.u.pageA.dwSize > PROPSHEETPAGEA_V1_SIZE) ? 1 : 0, "Expected ADDREF callback message\n");
} }
@ -1089,7 +1088,6 @@ static void test_CreatePropertySheetPage(void)
page.release_called = 0; page.release_called = 0;
ret = DestroyPropertySheetPage(hpsp); ret = DestroyPropertySheetPage(hpsp);
ok(ret, "Failed to destroy a page\n"); ok(ret, "Failed to destroy a page\n");
todo_wine
ok(page.release_called == 1, "Expected RELEASE callback message\n"); ok(page.release_called == 1, "Expected RELEASE callback message\n");
} }
} }
@ -1111,7 +1109,6 @@ static void test_CreatePropertySheetPage(void)
else else
{ {
ok(hpsp != NULL, "Failed to create a page, size %u\n", page.u.pageW.dwSize); ok(hpsp != NULL, "Failed to create a page, size %u\n", page.u.pageW.dwSize);
todo_wine_if(page.u.pageW.dwSize > PROPSHEETPAGEW_V1_SIZE)
ok(page.addref_called == (page.u.pageW.dwSize > PROPSHEETPAGEW_V1_SIZE) ? 1 : 0, "Expected ADDREF callback message\n"); ok(page.addref_called == (page.u.pageW.dwSize > PROPSHEETPAGEW_V1_SIZE) ? 1 : 0, "Expected ADDREF callback message\n");
} }
@ -1120,7 +1117,6 @@ static void test_CreatePropertySheetPage(void)
page.release_called = 0; page.release_called = 0;
ret = DestroyPropertySheetPage(hpsp); ret = DestroyPropertySheetPage(hpsp);
ok(ret, "Failed to destroy a page\n"); ok(ret, "Failed to destroy a page\n");
todo_wine
ok(page.release_called == 1, "Expected RELEASE callback message\n"); ok(page.release_called == 1, "Expected RELEASE callback message\n");
} }
} }