Commit bc3f40e2 authored by Alexander Lakhin's avatar Alexander Lakhin Committed by Alexandre Julliard

user32: Send WM_CTLCOLOR* message only for visible buttons.

parent 2c180741
...@@ -385,31 +385,34 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, ...@@ -385,31 +385,34 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
case WM_SETTEXT: case WM_SETTEXT:
{ {
/* Clear an old text here as Windows does */ /* Clear an old text here as Windows does */
HDC hdc = GetDC(hWnd); if (IsWindowVisible(hWnd))
HBRUSH hbrush; {
RECT client, rc; HDC hdc = GetDC(hWnd);
HWND parent = GetParent(hWnd); HBRUSH hbrush;
UINT message = (btn_type == BS_PUSHBUTTON || RECT client, rc;
btn_type == BS_DEFPUSHBUTTON || HWND parent = GetParent(hWnd);
btn_type == BS_USERBUTTON || UINT message = (btn_type == BS_PUSHBUTTON ||
btn_type == BS_OWNERDRAW) ? btn_type == BS_DEFPUSHBUTTON ||
WM_CTLCOLORBTN : WM_CTLCOLORSTATIC; btn_type == BS_USERBUTTON ||
btn_type == BS_OWNERDRAW) ?
if (!parent) parent = hWnd; WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
hbrush = (HBRUSH)SendMessageW(parent, message,
(WPARAM)hdc, (LPARAM)hWnd); if (!parent) parent = hWnd;
if (!hbrush) /* did the app forget to call DefWindowProc ? */ hbrush = (HBRUSH)SendMessageW(parent, message,
hbrush = (HBRUSH)DefWindowProcW(parent, message, (WPARAM)hdc, (LPARAM)hWnd);
(WPARAM)hdc, (LPARAM)hWnd); if (!hbrush) /* did the app forget to call DefWindowProc ? */
hbrush = (HBRUSH)DefWindowProcW(parent, message,
GetClientRect(hWnd, &client); (WPARAM)hdc, (LPARAM)hWnd);
rc = client;
BUTTON_CalcLabelRect(hWnd, hdc, &rc); GetClientRect(hWnd, &client);
/* Clip by client rect bounds */ rc = client;
if (rc.right > client.right) rc.right = client.right; BUTTON_CalcLabelRect(hWnd, hdc, &rc);
if (rc.bottom > client.bottom) rc.bottom = client.bottom; /* Clip by client rect bounds */
FillRect(hdc, &rc, hbrush); if (rc.right > client.right) rc.right = client.right;
ReleaseDC(hWnd, hdc); if (rc.bottom > client.bottom) rc.bottom = client.bottom;
FillRect(hdc, &rc, hbrush);
ReleaseDC(hWnd, hdc);
}
if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam ); if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam ); else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam );
......
...@@ -5938,7 +5938,7 @@ static void test_button_messages(void) ...@@ -5938,7 +5938,7 @@ static void test_button_messages(void)
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"Text 2"); SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"Text 2");
sprintf(desc, "button[%i]: WM_SETTEXT on an invisible button", i); 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(hwnd, SW_SHOW);
ShowWindow(parent, SW_HIDE); ShowWindow(parent, SW_HIDE);
...@@ -5947,7 +5947,7 @@ static void test_button_messages(void) ...@@ -5947,7 +5947,7 @@ static void test_button_messages(void)
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"Text 3"); SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"Text 3");
sprintf(desc, "button[%i]: WM_SETTEXT on an invisible button", i); 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); ShowWindow(parent, SW_SHOW);
flush_events(); flush_events();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment