Module: wine Branch: master Commit: 0ac74d180a28e9071f6bd711ef53fa16b1140653 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0ac74d180a28e9071f6bd711ef...
Author: Zebediah Figura z.figura12@gmail.com Date: Mon Mar 27 14:01:41 2017 -0500
user32: Always send WM_CANCELMODE when disabling a window.
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/tests/msg.c | 21 ++++++++++++++++++++- dlls/user32/win.c | 24 ++++++++++++------------ 2 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 19a1f31..fbadf7d 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1796,11 +1796,24 @@ static const struct message WmEnableWindowSeq_1[] =
static const struct message WmEnableWindowSeq_2[] = { + { WM_CANCELMODE, sent|wparam|lparam, 0, 0 }, + { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; + +static const struct message WmEnableWindowSeq_3[] = +{ { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 }, { WM_ENABLE, sent|wparam|lparam, TRUE, 0 }, { 0 } };
+static const struct message WmEnableWindowSeq_4[] = +{ + { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 }, + { 0 } +}; + static const struct message WmGetScrollRangeSeq[] = { { SBM_GETRANGE, sent }, @@ -5484,8 +5497,14 @@ static void test_messages(void) EnableWindow(hparent, FALSE); ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
+ EnableWindow(hparent, FALSE); + ok_sequence(WmEnableWindowSeq_2, "EnableWindow(FALSE)", FALSE); + + EnableWindow(hparent, TRUE); + ok_sequence(WmEnableWindowSeq_3, "EnableWindow(TRUE)", FALSE); + EnableWindow(hparent, TRUE); - ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE); + ok_sequence(WmEnableWindowSeq_4, "EnableWindow(TRUE)", FALSE);
flush_events(); flush_sequence(); diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 38604b4..5c27a01 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2152,23 +2152,23 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
TRACE("( %p, %d )\n", hwnd, enable);
- retvalue = !IsWindowEnabled( hwnd ); - - if (enable && retvalue) + if (enable) { - WIN_SetStyle( hwnd, 0, WS_DISABLED ); - SendMessageW( hwnd, WM_ENABLE, TRUE, 0 ); + retvalue = (WIN_SetStyle( hwnd, 0, WS_DISABLED ) & WS_DISABLED) != 0; + if (retvalue) SendMessageW( hwnd, WM_ENABLE, TRUE, 0 ); } - else if (!enable && !retvalue) + else { - SendMessageW( hwnd, WM_CANCELMODE, 0, 0); - - WIN_SetStyle( hwnd, WS_DISABLED, 0 ); + SendMessageW( hwnd, WM_CANCELMODE, 0, 0 );
- if (hwnd == GetFocus()) - SetFocus( 0 ); /* A disabled window can't have the focus */ + retvalue = (WIN_SetStyle( hwnd, WS_DISABLED, 0 ) & WS_DISABLED) != 0; + if (!retvalue) + { + if (hwnd == GetFocus()) + SetFocus( 0 ); /* A disabled window can't have the focus */
- SendMessageW( hwnd, WM_ENABLE, FALSE, 0 ); + SendMessageW( hwnd, WM_ENABLE, FALSE, 0 ); + } } return retvalue; }