Author: tkreuzer
Date: Wed Jan 10 07:51:27 2007
New Revision: 25412
URL:
http://svn.reactos.org/svn/reactos?rev=25412&view=rev
Log:
remove focus from window, when it gets diabled
- fixes bug 843
See issue #843 for more details.
Modified:
trunk/reactos/dll/win32/user32/windows/input.c
Modified: trunk/reactos/dll/win32/user32/windows/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/i…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/input.c (original)
+++ trunk/reactos/dll/win32/user32/windows/input.c Wed Jan 10 07:51:27 2007
@@ -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 @@
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);
}