Author: jimtabor
Date: Fri Nov  4 13:16:48 2011
New Revision: 54288

URL: http://svn.reactos.org/svn/reactos?rev=54288&view=rev
Log:
[Win32k|User32]
- Move control color support to Win32k.

Modified:
    trunk/reactos/dll/win32/user32/controls/button.c
    trunk/reactos/dll/win32/user32/controls/listbox.c
    trunk/reactos/dll/win32/user32/include/ntwrapper.h
    trunk/reactos/dll/win32/user32/include/user32p.h
    trunk/reactos/dll/win32/user32/misc/misc.c
    trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c
    trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
    trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c

Modified: trunk/reactos/dll/win32/user32/controls/button.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/button.c?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/button.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/button.c [iso-8859-1] Fri Nov  4 
13:16:48 2011
@@ -335,10 +335,7 @@
             HBRUSH hBrush;
             HWND parent = GetParent(hWnd);
             if (!parent) parent = hWnd;
-            hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, 
(LPARAM)hWnd);
-            if (!hBrush) /* did the app forget to call defwindowproc ? */
-                hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
-                                                (WPARAM)hdc, (LPARAM)hWnd);
+            hBrush = GetControlColor( parent, hWnd, hdc, WM_CTLCOLORBTN);
             GetClientRect(hWnd, &rc);
             FillRect(hdc, &rc, hBrush);
         }
@@ -885,7 +882,7 @@
     if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
     parent = GetParent(hwnd);
     if (!parent) parent = hwnd;
-    SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
+    GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN);
 
     setup_clipping( hwnd, hDC );
 #ifdef __REACTOS__
@@ -1175,10 +1172,7 @@
 
     parent = GetParent(hwnd);
     if (!parent) parent = hwnd;
-    hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, 
(LPARAM)hwnd);
-    if (!hBrush) /* did the app forget to call defwindowproc ? */
-        hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
-                                       (WPARAM)hDC, (LPARAM)hwnd);
+    hBrush = GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN);
 
     FillRect( hDC, &rc, hBrush );
     if ((action == ODA_FOCUS) ||
@@ -1219,7 +1213,7 @@
     if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, 
hFont );
     parent = GetParent(hwnd);
     if (!parent) parent = hwnd;
-    SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
+    GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN);
 
     setup_clipping( hwnd, hDC );
 

Modified: trunk/reactos/dll/win32/user32/controls/listbox.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/listbox.c?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/listbox.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/listbox.c [iso-8859-1] Fri Nov  4 
13:16:48 2011
@@ -660,8 +660,7 @@
     if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return;
     if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
     if (descr->font) oldFont = SelectObject( hdc, descr->font );
-    hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
-                                  (WPARAM)hdc, (LPARAM)descr->self );
+    hbrush = GetControlColor( descr->owner, descr->self, hdc, 
WM_CTLCOLORLISTBOX);
     if (hbrush) oldBrush = SelectObject( hdc, hbrush );
     if (!IsWindowEnabled(descr->self))
         SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
@@ -1032,8 +1031,7 @@
     }
 
     if (descr->font) oldFont = SelectObject( hdc, descr->font );
-    hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
-                                  (WPARAM)hdc, (LPARAM)descr->self );
+    hbrush = GetControlColor( descr->owner, descr->self, hdc, 
WM_CTLCOLORLISTBOX);
     if (hbrush) oldBrush = SelectObject( hdc, hbrush );
     if (!IsWindowEnabled(descr->self)) SetTextColor( hdc, GetSysColor( 
COLOR_GRAYTEXT ) );
 
@@ -3162,8 +3160,7 @@
         if ((IS_OWNERDRAW(descr)) && !(descr->style & LBS_DISPLAYCHANGED))
         {
             RECT rect;
-            HBRUSH hbrush = (HBRUSH)SendMessageW( descr->owner, 
WM_CTLCOLORLISTBOX,
-                                              wParam, (LPARAM)descr->self );
+            HBRUSH hbrush = GetControlColor( descr->owner, descr->self, 
(HDC)wParam, WM_CTLCOLORLISTBOX);
            TRACE("hbrush = %p\n", hbrush);
            if(!hbrush)
                hbrush = GetSysColorBrush(COLOR_WINDOW);

Modified: trunk/reactos/dll/win32/user32/include/ntwrapper.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/ntwrapper.h?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/include/ntwrapper.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/ntwrapper.h [iso-8859-1] Fri Nov  4 
13:16:48 2011
@@ -240,6 +240,16 @@
     return NtUserGetClipCursor(lpRect);
 }
 
+EXTINLINE HBRUSH WINAPI GetControlBrush(HWND hwnd, HDC  hdc, UINT ctlType)
+{
+    return NtUserGetControlBrush(hwnd, hdc, ctlType);
+}
+
+EXTINLINE HBRUSH WINAPI GetControlColor(HWND hwndParent, HWND hwnd, HDC hdc, 
UINT CtlMsg)
+{
+    return NtUserGetControlColor(hwndParent, hwnd, hdc, CtlMsg);
+}
+
 EXTINLINE BOOL WINAPI
 GetCursorInfo(PCURSORINFO pci)
 {

Modified: trunk/reactos/dll/win32/user32/include/user32p.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/user32p.h?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] Fri Nov  4 
13:16:48 2011
@@ -100,7 +100,5 @@
 HWND* WIN_ListChildren (HWND hWndparent);
 VOID DeleteFrameBrushes(VOID);
 BOOL WINAPI GdiValidateHandle(HGDIOBJ);
-HBRUSH FASTCALL GetControlColor(HWND,HWND,HDC,UINT);
-HBRUSH FASTCALL GetControlBrush(HWND,HDC,UINT);
 
 /* EOF */

Modified: trunk/reactos/dll/win32/user32/misc/misc.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/misc.c?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] Fri Nov  4 13:16:48 
2011
@@ -481,45 +481,6 @@
     return ValidateHwnd(hwnd);
 }
 
-HBRUSH
-FASTCALL
-GetControlColor(
-   HWND hwndParent,
-   HWND hwnd,
-   HDC hdc,
-   UINT CtlMsg)
-{
-    PWND pwnd;
-    HBRUSH hBrush;
-
-    if (!hwndParent) hwndParent = hwnd;
-
-    pwnd = ValidateHwnd(hwndParent);
-    if (pwnd && !TestWindowProcess(pwnd))
-    {
-       return (HBRUSH)DefWindowProcW( hwndParent, CtlMsg, (WPARAM)hdc, 
(LPARAM)hwnd);
-    }
-
-    hBrush = (HBRUSH)SendMessageW( hwndParent, CtlMsg, (WPARAM)hdc, 
(LPARAM)hwnd);
-
-    if (!hBrush || !GdiValidateHandle(hBrush))
-    {
-       hBrush = (HBRUSH)DefWindowProcW( hwndParent, CtlMsg, (WPARAM)hdc, 
(LPARAM)hwnd);
-    }
-    return hBrush;
-}
-
-HBRUSH
-FASTCALL
-GetControlBrush(
-   HWND hwnd,
-   HDC  hdc,
-   UINT ctlType)
-{
-    HWND hwndParent = GetParent(hwnd);
-    return GetControlColor( hwndParent, hwnd, hdc, ctlType);
-}
-
 /*
  * @implemented
  */

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/defwnd.c [iso-8859-1] Fri Nov  
4 13:16:48 2011
@@ -94,6 +94,43 @@
    return lResult;
 }
 
+HBRUSH FASTCALL
+DefWndControlColor(HDC hDC, UINT ctlType)
+{
+  if (ctlType == CTLCOLOR_SCROLLBAR)
+  {
+      HBRUSH hb = IntGetSysColorBrush(COLOR_SCROLLBAR);
+      COLORREF bk = IntGetSysColor(COLOR_3DHILIGHT);
+      IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_3DFACE));
+      IntGdiSetBkColor(hDC, bk);
+
+      /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
+       * we better use 0x55aa bitmap brush to make scrollbar's background
+       * look different from the window background.
+       */
+      if ( bk == IntGetSysColor(COLOR_WINDOW))
+          return gpsi->hbrGray;
+
+      NtGdiUnrealizeObject( hb );
+      return hb;
+  }
+
+  IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_WINDOWTEXT));
+
+  if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
+  {
+      IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_WINDOW));
+  }
+  else
+  {
+      IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_3DFACE));
+      return IntGetSysColorBrush(COLOR_3DFACE);
+  }
+
+  return IntGetSysColorBrush(COLOR_WINDOW);
+}
+
+
 LRESULT FASTCALL
 DefWndHandleSysCommand(PWND pWnd, WPARAM wParam, LPARAM lParam)
 {
@@ -168,10 +205,30 @@
       case WM_CLIENTSHUTDOWN:
          return IntClientShutdown(Wnd, wParam, lParam);
 
+      case WM_CTLCOLORMSGBOX:
+      case WM_CTLCOLOREDIT:
+      case WM_CTLCOLORLISTBOX:
+      case WM_CTLCOLORBTN:
+      case WM_CTLCOLORDLG:
+      case WM_CTLCOLORSTATIC:
+      case WM_CTLCOLORSCROLLBAR:
+           return (LRESULT) DefWndControlColor((HDC)wParam, Msg - 
WM_CTLCOLORMSGBOX);
+
+      case WM_CTLCOLOR:
+           return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam));
+
       case WM_GETHOTKEY:
          return DefWndGetHotKey(UserHMGetHandle(Wnd));                
       case WM_SETHOTKEY:
          return DefWndSetHotKey(Wnd, wParam);
+
+      case WM_NCHITTEST:
+      {
+         POINT Point;
+         Point.x = GET_X_LPARAM(lParam);
+         Point.y = GET_Y_LPARAM(lParam);
+         return GetNCHitEx(Wnd, Point);
+      }
 
       /* ReactOS only. */
       case WM_CBT:

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/misc.c?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] Fri Nov  4 
13:16:48 2011
@@ -53,6 +53,90 @@
   }
   TRACE("Language ID = %x\n",Ret);
   return (SHORT) Ret;
+}
+
+HBRUSH
+FASTCALL
+GetControlColor(
+   PWND pwndParent,
+   PWND pwnd,
+   HDC hdc,
+   UINT CtlMsg)
+{
+    HBRUSH hBrush;
+
+    if (!pwndParent) pwndParent = pwnd;
+
+    if ( pwndParent->head.pti->ppi != PsGetCurrentProcessWin32Process())
+    {
+       return (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, 
(LPARAM)UserHMGetHandle(pwnd), FALSE);
+    }
+
+    hBrush = (HBRUSH)co_IntSendMessage( UserHMGetHandle(pwndParent), CtlMsg, 
(WPARAM)hdc, (LPARAM)UserHMGetHandle(pwnd));
+
+    if (!hBrush || !GreIsHandleValid(hBrush))
+    {
+       hBrush = (HBRUSH)IntDefWindowProc( pwndParent, CtlMsg, (WPARAM)hdc, 
(LPARAM)UserHMGetHandle(pwnd), FALSE);
+    }
+    return hBrush;
+}
+
+HBRUSH
+FASTCALL
+GetControlBrush(
+   PWND pwnd,
+   HDC  hdc,
+   UINT ctlType)
+{
+    PWND pwndParent = IntGetParent(pwnd);
+    return GetControlColor( pwndParent, pwnd, hdc, ctlType);
+}
+
+HBRUSH
+APIENTRY
+NtUserGetControlBrush(
+   HWND hwnd,
+   HDC  hdc,
+   UINT ctlType)
+{
+   PWND pwnd;
+   HBRUSH hBrush = NULL;
+
+   UserEnterExclusive();
+   if ( (pwnd = UserGetWindowObject(hwnd)) &&
+       ((ctlType - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
+        hdc )
+   {
+      hBrush = GetControlBrush(pwnd, hdc, ctlType);
+   }
+   UserLeave();
+   return hBrush;
+}
+
+/*
+ * Called from PaintRect, works almost like wine PaintRect16 but returns 
hBrush.
+ */
+HBRUSH
+APIENTRY
+NtUserGetControlColor(
+   HWND hwndParent,
+   HWND hwnd,
+   HDC hdc,
+   UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush
+{
+   PWND pwnd, pwndParent = NULL;
+   HBRUSH hBrush = NULL;
+
+   UserEnterExclusive();
+   if ( (pwnd = UserGetWindowObject(hwnd)) &&
+       ((CtlMsg - WM_CTLCOLORMSGBOX) < CTLCOLOR_MAX) &&
+        hdc )
+   {
+      if (hwndParent) pwndParent = UserGetWindowObject(hwndParent);
+      hBrush = GetControlColor( pwndParent, pwnd, hdc, CtlMsg);
+   }
+   UserLeave();
+   return hBrush;
 }
 
 /*

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c?rev=54288&r1=54287&r2=54288&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] 
(original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] Fri Nov 
 4 13:16:48 2011
@@ -202,35 +202,6 @@
    LPWSTR pszItemText,
    UINT   cchItemText,
    BOOL   Ansi)
-{
-   STUB
-
-   return 0;
-}
-
-HBRUSH
-APIENTRY
-NtUserGetControlBrush(
-   HWND hwnd,
-   HDC  hdc,
-   UINT ctlType)
-{
-   STUB
-
-   return 0;
-}
-
-
-/*
- * Called from PaintRect, works almost like wine PaintRect16 but returns 
hBrush.
- */
-HBRUSH
-APIENTRY
-NtUserGetControlColor(
-   HWND hwndParent,
-   HWND hwnd,
-   HDC hdc,
-   UINT CtlMsg) // Wine PaintRect: WM_CTLCOLORMSGBOX + hbrush
 {
    STUB
 


Reply via email to