- [User32] Send WM_CANCELMODE in EnableWindow.
authorJames Tabor <james.tabor@reactos.org>
Wed, 10 Mar 2010 10:19:49 +0000 (10:19 +0000)
committerJames Tabor <james.tabor@reactos.org>
Wed, 10 Mar 2010 10:19:49 +0000 (10:19 +0000)
svn path=/trunk/; revision=46054

reactos/dll/win32/user32/windows/input.c

index 8146726..4e97b0d 100644 (file)
@@ -109,30 +109,39 @@ BOOL WINAPI
 EnableWindow(HWND hWnd,
             BOOL bEnable)
 {
+    // This will soon be moved to win32k.
+    BOOL Update;
     LONG Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
     /* check if updating is needed */
     UINT bIsDisabled = (Style & WS_DISABLED);
-    if ( (bIsDisabled && bEnable) || (!bIsDisabled && !bEnable) )
+    Update = bIsDisabled;
+
+    if (bEnable)
     {
-        if (bEnable)
-        {
-            Style &= ~WS_DISABLED;
-        }
-        else
-        {
-            Style |= WS_DISABLED;
-            /* Remove keyboard focus from that window if it had focus */
-            if (hWnd == GetFocus())
-            {
-               SetFocus(NULL);
-            }
-        }
-        NtUserSetWindowLong(hWnd, GWL_STYLE, Style, FALSE);
+       Style &= ~WS_DISABLED;
+    }
+    else
+    {
+       Update = !bIsDisabled;
+
+       SendMessageW( hWnd, WM_CANCELMODE, 0, 0);
 
-        SendMessageA(hWnd, WM_ENABLE, (LPARAM) IsWindowEnabled(hWnd), 0);
+       /* Remove keyboard focus from that window if it had focus */
+       if (hWnd == GetFocus())
+       {
+          SetFocus(NULL);
+       }
+       Style |= WS_DISABLED;
+    }
+
+    NtUserSetWindowLong(hWnd, GWL_STYLE, Style, FALSE);
+    
+    if (Update)
+    {
+        SendMessageW(hWnd, WM_ENABLE, (LPARAM)bEnable, 0);
     }
     // Return nonzero if it was disabled, or zero if it wasn't:
-    return IsWindowEnabled(hWnd);
+    return bIsDisabled;
 }