From: Alexander LAW <exclusion@gmail.com>
Subject: user32: Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
Message-Id: <4D471491.4060400@gmail.com>
Date: Mon, 31 Jan 2011 22:59:13 +0300

Fixes bug #25790

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Fixes bug #25790
    <style type="text/css">p { margin-bottom: 0.21cm; }</style>
  </body>
</html>

From c606ab13b50616bb58db8ca92c839e1b55fc6715 Mon Sep 17 00:00:00 2001
From: Alexander LAW <exclusion@gmail.com>
Date: Mon, 31 Jan 2011 22:15:34 +0300
Subject: user32: Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
 Fixes bug #25790

---
 dlls/user32/button.c |   49 +++++++++++++++++++++++++++++--------------------
 1 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index b15b36b..6266d13 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -384,26 +384,35 @@ 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);
-
-        if (!parent) parent = hWnd;
-        hbrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
-				      (WPARAM)hdc, (LPARAM)hWnd);
-        if (!hbrush) /* did the app forget to call DefWindowProc ? */
-            hbrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
-					    (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 (style & WS_VISIBLE)
+        {
+            HDC hdc = GetDC(hWnd);
+            HBRUSH hbrush;
+            RECT client, rc;
+            HWND parent = GetParent(hWnd);
+            UINT ctlMessage=(btn_type == BS_PUSHBUTTON ||
+                      btn_type == BS_DEFPUSHBUTTON ||
+                      btn_type == BS_PUSHLIKE ||
+                      btn_type == BS_USERBUTTON ||
+                      btn_type == BS_OWNERDRAW) ?
+                      WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
+
+            if (!parent) parent = hWnd;
+            hbrush = (HBRUSH)SendMessageW(parent, ctlMessage,
+                                   (WPARAM)hdc, (LPARAM)hWnd);
+            if (!hbrush) /* did the app forget to call DefWindowProc ? */
+            hbrush = (HBRUSH)DefWindowProcW(parent, ctlMessage,
+                                     (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 );
-- 
1.7.1