[USER32]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Wed, 25 Feb 2015 20:02:10 +0000 (20:02 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Wed, 25 Feb 2015 20:02:10 +0000 (20:02 +0000)
- button.c: Use NtUserAlterWindowStyle where wine uses WIN_SetStyle (usage and parameters were confirmed with windbg)

[NTUSER]
- Implement NtUserAlterWindowStyle.

Fixes remaining failures in user32:msg_controls test.

svn path=/trunk/; revision=66457

reactos/win32ss/user/ntuser/ntstubs.c
reactos/win32ss/user/ntuser/window.c
reactos/win32ss/user/user32/controls/button.c

index 4d1c561..28fd1ae 100644 (file)
@@ -1157,19 +1157,6 @@ NtUserQuerySendMessage(DWORD Unknown0)
     return 0;
 }
 
-/*
- * @unimplemented
- */
-DWORD APIENTRY
-NtUserAlterWindowStyle(DWORD Unknown0,
-                       DWORD Unknown1,
-                       DWORD Unknown2)
-{
-   STUB
-
-   return(0);
-}
-
 BOOL APIENTRY NtUserAddClipboardFormatListener(
     HWND hwnd
 )
index ef820ce..aa3122d 100644 (file)
@@ -3537,8 +3537,8 @@ IntCheckFrameEdge(ULONG Style, ULONG ExStyle)
       return FALSE;
 }
 
-LONG FASTCALL
-co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
+static LONG
+co_IntSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi, BOOL bAlter)
 {
    PWND Window, Parent;
    PWINSTATION_OBJECT WindowStation;
@@ -3597,6 +3597,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
                Style.styleNew &= ~WS_EX_WINDOWEDGE;
 
             Window->ExStyle = (DWORD)Style.styleNew;
+
             co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style);
             break;
 
@@ -3604,7 +3605,9 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
             OldValue = (LONG) Window->style;
             Style.styleOld = OldValue;
             Style.styleNew = NewValue;
-            co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
+
+            if (!bAlter)
+                co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style);
 
            /* WS_CLIPSIBLINGS can't be reset on top-level windows */
             if (Window->spwndParent == UserGetDesktopWindow()) Style.styleNew |= WS_CLIPSIBLINGS;
@@ -3621,7 +3624,9 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
                DceResetActiveDCEs( Window );
             }
             Window->style = (DWORD)Style.styleNew;
-            co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
+
+            if (!bAlter)
+                co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style);
             break;
 
          case GWL_WNDPROC:
@@ -3672,6 +3677,13 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
    return( OldValue);
 }
 
+
+LONG FASTCALL
+co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
+{
+    return co_IntSetWindowLong(hWnd, Index, NewValue, Ansi, FALSE);
+}
+
 /*
  * NtUserSetWindowLong
  *
@@ -3686,25 +3698,46 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 LONG APIENTRY
 NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi)
 {
-   DECLARE_RETURN(LONG);
+   LONG ret;
 
-   TRACE("Enter NtUserSetWindowLong\n");
    UserEnterExclusive();
 
    if (hWnd == IntGetDesktopWindow())
    {
       EngSetLastError(STATUS_ACCESS_DENIED);
-      RETURN( 0);
+      UserLeave();
+      return 0;
    }
 
-   RETURN( co_UserSetWindowLong(hWnd, Index, NewValue, Ansi));
+   ret = co_IntSetWindowLong(hWnd, Index, NewValue, Ansi, FALSE);
 
-CLEANUP:
-   TRACE("Leave NtUserSetWindowLong, ret=%i\n",_ret_);
    UserLeave();
-   END_CLEANUP;
+   
+   return ret;
 }
 
+DWORD APIENTRY
+NtUserAlterWindowStyle(HWND hWnd, DWORD Index, LONG NewValue)
+{
+   LONG ret;
+
+   UserEnterExclusive();
+
+   if (hWnd == IntGetDesktopWindow())
+   {
+      EngSetLastError(STATUS_ACCESS_DENIED);
+      UserLeave();
+      return 0;
+   }
+
+   ret = co_IntSetWindowLong(hWnd, Index, NewValue, FALSE, TRUE);
+
+   UserLeave();
+   
+   return ret;
+}
+
+
 /*
  * NtUserSetWindowWord
  *
index 3846c73..ac9b924 100644 (file)
@@ -298,11 +298,10 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
         /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
         if (btn_type == BS_USERBUTTON )
         {
-#ifdef __REACTOS__
             style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON;
-            SetWindowLongPtrW( hWnd, GWL_STYLE, style );
+#ifdef __REACTOS__
+            NtUserAlterWindowStyle(hWnd, GWL_STYLE, style );
 #else
-            style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON;
             WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style );
 #endif
         }
@@ -508,8 +507,11 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
         if ((wParam & BS_TYPEMASK) >= MAX_BTN_TYPE) break;
         btn_type = wParam & BS_TYPEMASK;
         style = (style & ~BS_TYPEMASK) | btn_type;
-        SetWindowLongPtrW( hWnd, GWL_STYLE, style );
-        //WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style );
+#ifdef __REACTOS__
+            NtUserAlterWindowStyle(hWnd, GWL_STYLE, style );
+#else
+            WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style );
+#endif
 
         /* Only redraw if lParam flag is set.*/
         if (lParam)
@@ -565,7 +567,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
 #ifdef __REACTOS__
             if (wParam) style |= WS_TABSTOP;
             else style &= ~WS_TABSTOP;
-            SetWindowLongPtrW( hWnd, GWL_STYLE, style );
+            NtUserAlterWindowStyle(hWnd, GWL_STYLE, style );
 #else
             if (wParam) WIN_SetStyle( hWnd, WS_TABSTOP, 0 );
             else WIN_SetStyle( hWnd, 0, WS_TABSTOP );