[3/3] user32: Send WM_CTLCOLOR* message only for visible buttons.

Sebastian Lackner sebastian at fds-team.de
Tue Apr 19 15:15:24 CDT 2016


From: Alexander Lakhin <exclusion at gmail.com>

Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
 dlls/user32/button.c    |   53 +++++++++++++++++++++++++-----------------------
 dlls/user32/tests/msg.c |    4 +--
 2 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index efd74f9..13fc746 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -385,31 +385,34 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
     case WM_SETTEXT:
     {
         /* Clear an old text here as Windows does */
-        HDC hdc = GetDC(hWnd);
-        HBRUSH hbrush;
-        RECT client, rc;
-        HWND parent = GetParent(hWnd);
-        UINT message = (btn_type == BS_PUSHBUTTON ||
-                        btn_type == BS_DEFPUSHBUTTON ||
-                        btn_type == BS_USERBUTTON ||
-                        btn_type == BS_OWNERDRAW) ?
-                        WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
-
-        if (!parent) parent = hWnd;
-        hbrush = (HBRUSH)SendMessageW(parent, message,
-                                      (WPARAM)hdc, (LPARAM)hWnd);
-        if (!hbrush) /* did the app forget to call DefWindowProc ? */
-            hbrush = (HBRUSH)DefWindowProcW(parent, message,
-                                            (WPARAM)hdc, (LPARAM)hWnd);
-
-        GetClientRect(hWnd, &client);
-        rc = client;
-        BUTTON_CalcLabelRect(hWnd, hdc, &rc);
-        /* Clip by client rect bounds */
-        if (rc.right > client.right) rc.right = client.right;
-        if (rc.bottom > client.bottom) rc.bottom = client.bottom;
-        FillRect(hdc, &rc, hbrush);
-        ReleaseDC(hWnd, hdc);
+        if (IsWindowVisible(hWnd))
+        {
+            HDC hdc = GetDC(hWnd);
+            HBRUSH hbrush;
+            RECT client, rc;
+            HWND parent = GetParent(hWnd);
+            UINT message = (btn_type == BS_PUSHBUTTON ||
+                            btn_type == BS_DEFPUSHBUTTON ||
+                            btn_type == BS_USERBUTTON ||
+                            btn_type == BS_OWNERDRAW) ?
+                            WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
+
+            if (!parent) parent = hWnd;
+            hbrush = (HBRUSH)SendMessageW(parent, message,
+                                          (WPARAM)hdc, (LPARAM)hWnd);
+            if (!hbrush) /* did the app forget to call DefWindowProc ? */
+                hbrush = (HBRUSH)DefWindowProcW(parent, message,
+                                                (WPARAM)hdc, (LPARAM)hWnd);
+
+            GetClientRect(hWnd, &client);
+            rc = client;
+            BUTTON_CalcLabelRect(hWnd, hdc, &rc);
+            /* Clip by client rect bounds */
+            if (rc.right > client.right) rc.right = client.right;
+            if (rc.bottom > client.bottom) rc.bottom = client.bottom;
+            FillRect(hdc, &rc, hbrush);
+            ReleaseDC(hWnd, hdc);
+        }
 
         if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
         else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam );
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index d5ce34c..c3a1457 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -5938,7 +5938,7 @@ static void test_button_messages(void)
 
         SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"Text 2");
         sprintf(desc, "button[%i]: WM_SETTEXT on an invisible button", i);
-        ok_sequence(WmSetTextInvisibleSeq, desc, TRUE);
+        ok_sequence(WmSetTextInvisibleSeq, desc, FALSE);
 
         ShowWindow(hwnd, SW_SHOW);
         ShowWindow(parent, SW_HIDE);
@@ -5947,7 +5947,7 @@ static void test_button_messages(void)
 
         SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"Text 3");
         sprintf(desc, "button[%i]: WM_SETTEXT on an invisible button", i);
-        ok_sequence(WmSetTextInvisibleSeq, desc, TRUE);
+        ok_sequence(WmSetTextInvisibleSeq, desc, FALSE);
 
         ShowWindow(parent, SW_SHOW);
         flush_events();
-- 
2.7.1



More information about the wine-patches mailing list