comctl32: Property sheets must be able to redraw themselves even if no page is selected.

Francois Gouget fgouget at codeweavers.com
Mon Sep 5 17:13:38 CDT 2011


---
 dlls/comctl32/propsheet.c       |   11 +++++++----
 dlls/comctl32/tests/propsheet.c |   28 +++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/dlls/comctl32/propsheet.c b/dlls/comctl32/propsheet.c
index 3dd0713..e6d2d30 100644
--- a/dlls/comctl32/propsheet.c
+++ b/dlls/comctl32/propsheet.c
@@ -3201,17 +3201,20 @@ static LRESULT PROPSHEET_Paint(HWND hwnd, HDC hdcParam)
     WCHAR szBuffer[256];
     int nLength;
 
-    if (psInfo->active_page < 0) return 1;
     hdc = hdcParam ? hdcParam : BeginPaint(hwnd, &ps);
     if (!hdc) return 1;
 
     hdcSrc = CreateCompatibleDC(0);
-    ppshpage = (LPCPROPSHEETPAGEW)psInfo->proppage[psInfo->active_page].hpage;
 
     if (psInfo->ppshheader.dwFlags & PSH_USEHPLWATERMARK) 
 	hOldPal = SelectPalette(hdc, psInfo->ppshheader.hplWatermark, FALSE);
 
-    if ( (!(ppshpage->dwFlags & PSP_HIDEHEADER)) &&
+    if (psInfo->active_page < 0)
+        ppshpage = NULL;
+    else
+        ppshpage = (LPCPROPSHEETPAGEW)psInfo->proppage[psInfo->active_page].hpage;
+
+    if ( (ppshpage && !(ppshpage->dwFlags & PSP_HIDEHEADER)) &&
 	 (psInfo->ppshheader.dwFlags & (PSH_WIZARD97_OLD | PSH_WIZARD97_NEW)) &&
 	 (psInfo->ppshheader.dwFlags & PSH_HEADER) ) 
     {
@@ -3318,7 +3321,7 @@ static LRESULT PROPSHEET_Paint(HWND hwnd, HDC hdcParam)
 	SelectObject(hdcSrc, hbmp);
     }
 
-    if ( (ppshpage->dwFlags & PSP_HIDEHEADER) &&
+    if ( (ppshpage && (ppshpage->dwFlags & PSP_HIDEHEADER)) &&
 	 (psInfo->ppshheader.dwFlags & (PSH_WIZARD97_OLD | PSH_WIZARD97_NEW)) &&
 	 (psInfo->ppshheader.dwFlags & PSH_WATERMARK) ) 
     {
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c
index 89c548f..e6c2bb5 100644
--- a/dlls/comctl32/tests/propsheet.c
+++ b/dlls/comctl32/tests/propsheet.c
@@ -33,6 +33,24 @@ static LONG active_page = -1;
 
 #define IDC_APPLY_BUTTON 12321
 
+
+/* try to make sure pending X events have been processed before continuing */
+static void flush_events(void)
+{
+    MSG msg;
+    int diff = 200;
+    int min_timeout = 100;
+    DWORD time = GetTickCount() + diff;
+
+    while (diff > 0)
+    {
+        if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
+        while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
+        diff = time - GetTickCount();
+    }
+}
+
+
 static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
 {
     switch(msg)
@@ -121,7 +139,8 @@ static void test_nopage(void)
     HPROPSHEETPAGE hpsp[1];
     PROPSHEETPAGEA psp;
     PROPSHEETHEADERA psh;
-    HWND hdlg;
+    HWND hdlg, hpage;
+    MSG msg;
 
     memset(&psp, 0, sizeof(psp));
     psp.dwSize = sizeof(psp);
@@ -148,7 +167,14 @@ static void test_nopage(void)
 
     ShowWindow(hdlg,SW_NORMAL);
     SendMessage(hdlg, PSM_REMOVEPAGE, 0, 0);
+    hpage = PropSheet_GetCurrentPageHwnd(hdlg);
+    ok(hpage == NULL, "expected no current page, got %p, index=%d\n", hpage, PropSheet_HwndToIndex(hdlg, hpage));
+    flush_events();
     RedrawWindow(hdlg,NULL,NULL,RDW_UPDATENOW|RDW_ERASENOW);
+
+    /* Check that the property sheet was fully redrawn */
+    ok(!PeekMessage(&msg, 0, WM_PAINT, WM_PAINT, PM_NOREMOVE),
+       "expected no pending WM_PAINT messages\n");
     DestroyWindow(hdlg);
 }
 
-- 
1.7.5.4




More information about the wine-patches mailing list