user32: Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR* Fixes bug #25790

Alexander LAW exclusion at gmail.com
Mon Jan 31 13:15:34 CST 2011


---
 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


--------------090007090309040009090100--



More information about the wine-patches mailing list