From 733a3ec1b9d5a62ba47b289bd23e166ce55dcdf0 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 30 Mar 2018 13:20:46 +0300 Subject: [PATCH] comctl32/button: Improve button data layout compatibility. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/button.c | 2 ++ dlls/comctl32/tests/button.c | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index 8b5a654efc3..7d48fe79567 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -90,6 +90,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(button); typedef struct _BUTTON_INFO { HWND hwnd; + HWND parent; LONG state; HFONT font; WCHAR *note; @@ -342,6 +343,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L infoPtr = heap_alloc_zero( sizeof(*infoPtr) ); SetWindowLongPtrW( hWnd, 0, (LONG_PTR)infoPtr ); infoPtr->hwnd = hWnd; + infoPtr->parent = GetParent(hWnd); return DefWindowProcW(hWnd, uMsg, wParam, lParam); case WM_NCDESTROY: diff --git a/dlls/comctl32/tests/button.c b/dlls/comctl32/tests/button.c index 4c07f0adcd7..0aacfa5888f 100644 --- a/dlls/comctl32/tests/button.c +++ b/dlls/comctl32/tests/button.c @@ -979,6 +979,62 @@ static void register_parent_class(void) RegisterClassA(&cls); } +static void test_button_data(void) +{ + static const DWORD styles[] = + { + BS_PUSHBUTTON, + BS_DEFPUSHBUTTON, + BS_CHECKBOX, + BS_AUTOCHECKBOX, + BS_RADIOBUTTON, + BS_3STATE, + BS_AUTO3STATE, + BS_GROUPBOX, + BS_USERBUTTON, + BS_AUTORADIOBUTTON, + BS_OWNERDRAW, + BS_SPLITBUTTON, + BS_DEFSPLITBUTTON, + BS_COMMANDLINK, + BS_DEFCOMMANDLINK, + }; + + struct button_desc + { + HWND self; + HWND parent; + }; + unsigned int i; + HWND parent; + + parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok(parent != 0, "Failed to create parent window\n"); + + for (i = 0; i < ARRAY_SIZE(styles); i++) + { + struct button_desc *desc; + HWND hwnd; + + hwnd = create_button(styles[i], parent); + ok(hwnd != NULL, "Failed to create a button.\n"); + + desc = (void *)GetWindowLongPtrA(hwnd, 0); + ok(desc != NULL, "Expected window data.\n"); + + if (desc) + { + ok(desc->self == hwnd, "Unexpected 'self' field.\n"); + ok(desc->parent == parent, "Unexpected 'parent' field.\n"); + } + + DestroyWindow(hwnd); + } + + DestroyWindow(parent); +} + START_TEST(button) { ULONG_PTR ctx_cookie; @@ -995,6 +1051,7 @@ START_TEST(button) test_button_class(); test_button_messages(); test_note(); + test_button_data(); unload_v6_module(ctx_cookie, hCtx); }