user32: Button should get captured when highlighted with VK_SPACE (try2)

Nikolay Sivov bunglehead at gmail.com
Tue Mar 10 06:23:36 CDT 2009


You could easily reproduce this issue:
    - highlight any checkbox with space key
    - keep space pressed and changed focus (with arrows or tab)
After that checkbox will be unfocused but still highlighted wich is a bug.
The same applies of course to radiobuttons too.

With capturing redrawing works correctly (no hanged highlightings for checks and
radios).

P.S.
Selection with space key isn't complete (with this patch too).
I'll prepare some messaging tests for that. For example button shouldn't
lose focus when highlighted with space.

Changelog:
    - (try2) test added
    - Button should get captured when highlighted with VK_SPACE

>From 3a0fe30320e0e4926225b3844af37e1c7ef8b7d0 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Tue, 10 Mar 2009 07:09:35 -0400
Subject: Button should get captured when highlighted with VK_SPACE

---
 dlls/user32/button.c    |    1 +
 dlls/user32/tests/msg.c |   11 +++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index 84b54ab..f2097aa 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -309,6 +309,7 @@ static LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg,
 	{
 	    SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 );
             set_button_state( hWnd, get_button_state( hWnd ) | BUTTON_BTNPRESSED );
+            SetCapture( hWnd );
 	}
 	break;
 
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 3a20cba..81b0b0a 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -5209,6 +5209,17 @@ static void test_button_messages(void)
     DWORD dlg_code;
     HFONT zfont;
 
+    /* selection with VK_SPACE should capture button window */
+    hwnd = CreateWindowExA(0, "button", "test", BS_CHECKBOX | WS_VISIBLE | WS_POPUP,
+                           0, 0, 50, 14, 0, 0, 0, NULL);
+    ok(hwnd != 0, "Failed to create button window\n");
+    ReleaseCapture();
+    SetFocus(hwnd);
+    SendMessageA(hwnd, WM_KEYDOWN, VK_SPACE, 0);
+    ok(GetCapture() == hwnd, "Should be captured on VK_SPACE WM_KEYDOWN\n");
+    SendMessageA(hwnd, WM_KEYUP, VK_SPACE, 0);
+    DestroyWindow(hwnd);
+
     subclass_button();
 
     for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
-- 
1.5.6.5





More information about the wine-patches mailing list