diff --git a/reactos/dll/win32/user32/windows/input.c b/reactos/dll/win32/user32/windows/input.c index 6f7bac23902..43305ae3595 100644 --- a/reactos/dll/win32/user32/windows/input.c +++ b/reactos/dll/win32/user32/windows/input.c @@ -36,6 +36,7 @@ /* Directory to load key layouts from */ #define SYSTEMROOT_DIR L"\\SystemRoot\\System32\\" +#define STATE_GWL_OFFSET 0 /* GLOBALS *******************************************************************/ @@ -338,11 +339,24 @@ EnableWindow(HWND hWnd, BOOL bEnable) { LONG Style = NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE); - Style = bEnable ? Style & ~WS_DISABLED : Style | WS_DISABLED; - NtUserSetWindowLong(hWnd, GWL_STYLE, Style, FALSE); - - SendMessageA(hWnd, WM_ENABLE, (LPARAM) IsWindowEnabled(hWnd), 0); + /* check if updating is needed */ + UINT bIsDisabled = (Style & WS_DISABLED); + if ( (bIsDisabled && bEnable) || (!bIsDisabled && !bEnable) ) + { + if (bEnable) + { + Style &= ~WS_DISABLED; + } + else + { + /* Remove keyboard focus from that window */ + SetFocus(NULL); + Style |= WS_DISABLED; + } + NtUserSetWindowLong(hWnd, GWL_STYLE, Style, FALSE); + SendMessageA(hWnd, WM_ENABLE, (LPARAM) IsWindowEnabled(hWnd), 0); + } // Return nonzero if it was disabled, or zero if it wasn't: return IsWindowEnabled(hWnd); }