From: James Tabor Date: Fri, 4 Nov 2011 13:16:48 +0000 (+0000) Subject: [Win32k|User32] X-Git-Tag: backups/iut-netsh@54410~100 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=bc031d7389622fac5b08679bf5457e4dbf868893 [Win32k|User32] - Move control color support to Win32k. svn path=/trunk/; revision=54288 --- diff --git a/reactos/dll/win32/user32/controls/button.c b/reactos/dll/win32/user32/controls/button.c index bc5cb41efe4..af205c5dd8e 100644 --- a/reactos/dll/win32/user32/controls/button.c +++ b/reactos/dll/win32/user32/controls/button.c @@ -335,10 +335,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, 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 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) 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 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action ) 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 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action ) 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 ); diff --git a/reactos/dll/win32/user32/controls/listbox.c b/reactos/dll/win32/user32/controls/listbox.c index 2dafc9217dd..07165d397ee 100644 --- a/reactos/dll/win32/user32/controls/listbox.c +++ b/reactos/dll/win32/user32/controls/listbox.c @@ -660,8 +660,7 @@ static void LISTBOX_RepaintItem( LB_DESCR *descr, INT index, UINT action ) 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 @@ static LRESULT LISTBOX_Paint( LB_DESCR *descr, HDC hdc ) } 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 @@ LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg, 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); diff --git a/reactos/dll/win32/user32/include/ntwrapper.h b/reactos/dll/win32/user32/include/ntwrapper.h index 3ba2d50fd88..7e7873d3cc0 100644 --- a/reactos/dll/win32/user32/include/ntwrapper.h +++ b/reactos/dll/win32/user32/include/ntwrapper.h @@ -240,6 +240,16 @@ GetClipCursor(LPRECT lpRect) 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) { diff --git a/reactos/dll/win32/user32/include/user32p.h b/reactos/dll/win32/user32/include/user32p.h index 82f68722400..b7d8affdb43 100644 --- a/reactos/dll/win32/user32/include/user32p.h +++ b/reactos/dll/win32/user32/include/user32p.h @@ -100,7 +100,5 @@ BOOL UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT, BOOL down ); 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 */ diff --git a/reactos/dll/win32/user32/misc/misc.c b/reactos/dll/win32/user32/misc/misc.c index 33e1ca74ed8..b729f3d889d 100644 --- a/reactos/dll/win32/user32/misc/misc.c +++ b/reactos/dll/win32/user32/misc/misc.c @@ -481,45 +481,6 @@ ValidateHwndOrDesk(HWND hwnd) 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 */ diff --git a/reactos/subsystems/win32/win32k/ntuser/defwnd.c b/reactos/subsystems/win32/win32k/ntuser/defwnd.c index b52f2b3ebe5..b56a1117204 100644 --- a/reactos/subsystems/win32/win32k/ntuser/defwnd.c +++ b/reactos/subsystems/win32/win32k/ntuser/defwnd.c @@ -94,6 +94,43 @@ IntClientShutdown( 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,11 +205,31 @@ IntDefWindowProc( 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: { diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index 35cced101ee..4542a26a94d 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -55,6 +55,90 @@ IntGdiGetLanguageID(VOID) 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; +} + /* * @unimplemented */ diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index d0cd8e92056..2160be9a5c8 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -208,35 +208,6 @@ NtUserGetAltTabInfo( 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 - - return 0; -} - DWORD APIENTRY NtUserGetImeHotKey(