Propsheet exception fix

Aric Stewart aric at codeweavers.com
Tue Apr 3 12:58:19 CDT 2007


Do not attempt to draw a page during WM_PAINT if there is no active page.
Test which shows this working, causes exception without this patch
Exception pointed out by EA Durbin.
---
  dlls/comctl32/propsheet.c       |    1 +
  dlls/comctl32/tests/propsheet.c |   37 
+++++++++++++++++++++++++++++++++++++
  2 files changed, 38 insertions(+), 0 deletions(-)
-------------- next part --------------
diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c
index c84f23a..201e554 100644
--- a/dlls/comctl32/propsheet.c
+++ b/dlls/comctl32/propsheet.c
@@ -3229,6 +3229,7 @@ static LRESULT PROPSHEET_Paint(HWND hwnd
     WCHAR szBuffer[256];
     int nLength;
 
+    if (psInfo->active_page < 0) return 1;
     hdc = hdcParam ? hdcParam : BeginPaint(hwnd, &ps);
     if (!hdc) return 1;
 
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c
index db71bfe..2491e9f 100644
--- a/dlls/comctl32/tests/propsheet.c
+++ b/dlls/comctl32/tests/propsheet.c
@@ -98,7 +98,44 @@ static void test_title(void)
     DestroyWindow(hdlg);
 }
 
+static void test_nopage(void)
+{
+    HPROPSHEETPAGE hpsp[1];
+    PROPSHEETPAGEA psp;
+    PROPSHEETHEADERA psh;
+    HWND hdlg;
+
+    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);
+    ShowWindow(hdlg,SW_NORMAL);
+    SendMessage(hdlg, PSM_REMOVEPAGE, 0, 0);
+    RedrawWindow(hdlg,NULL,NULL,RDW_UPDATENOW|RDW_ERASENOW);
+    DestroyWindow(hdlg);
+}
+
+
+
 START_TEST(propsheet)
 {
     test_title();
+    test_nopage();
 }


More information about the wine-patches mailing list