From: Alexander LAW 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 Fixes bug #25790 From c606ab13b50616bb58db8ca92c839e1b55fc6715 Mon Sep 17 00:00:00 2001 From: Alexander LAW 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