From b4fea4f2f0df40976f50d396e9e4046929697879 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 27 Mar 2017 14:01:40 -0500 Subject: [PATCH] user32: Don't call ReleaseCapture() in EnableWindow(). Killing the capture is already handled in DefWindowProc(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/user32/tests/win.c | 26 ++++++++++++++++++++++++++ dlls/user32/win.c | 6 ------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index f0ea18262cb..fef9cb0029b 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -6561,8 +6561,16 @@ static DWORD CALLBACK enablewindow_thread(LPVOID arg) return 0; } +static LRESULT CALLBACK enable_window_procA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_CANCELMODE) + return 0; + return DefWindowProcA(hwnd, msg, wParam, lParam); +} + static void test_EnableWindow(void) { + WNDCLASSA cls; HWND hwnd; HANDLE hthread; DWORD tid; @@ -6604,6 +6612,24 @@ static void test_EnableWindow(void) CloseHandle(hthread); DestroyWindow(hwnd); + + /* test preventing release of capture */ + memset(&cls, 0, sizeof(cls)); + cls.lpfnWndProc = enable_window_procA; + cls.hInstance = GetModuleHandleA(0); + cls.lpszClassName = "EnableWindowClass"; + ok(RegisterClassA(&cls), "RegisterClass failed\n"); + + hwnd = CreateWindowExA(0, "EnableWindowClass", NULL, WS_OVERLAPPEDWINDOW, + 0, 0, 100, 100, 0, 0, 0, NULL); + assert(hwnd); + SetFocus(hwnd); + SetCapture(hwnd); + + EnableWindow(hwnd, FALSE); + check_wnd_state(hwnd, hwnd, 0, hwnd); + + DestroyWindow(hwnd); } static DWORD CALLBACK gettext_msg_thread( LPVOID arg ) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index f3b4ef547c6..38604b4e05d 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2161,8 +2161,6 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable ) } else if (!enable && !retvalue) { - HWND capture_wnd; - SendMessageW( hwnd, WM_CANCELMODE, 0, 0); WIN_SetStyle( hwnd, WS_DISABLED, 0 ); @@ -2170,10 +2168,6 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable ) if (hwnd == GetFocus()) SetFocus( 0 ); /* A disabled window can't have the focus */ - capture_wnd = GetCapture(); - if (capture_wnd && (hwnd == capture_wnd || IsChild(hwnd, capture_wnd))) - ReleaseCapture(); /* A disabled window can't capture the mouse */ - SendMessageW( hwnd, WM_ENABLE, FALSE, 0 ); } return retvalue;