From 9dded144f4d3e16933b11cf8bd01676cd9d14d6e Mon Sep 17 00:00:00 2001 From: Patrik Stridvall Date: Wed, 5 Jan 2000 03:05:23 +0000 Subject: [PATCH] - Made FillRect behave like it does on Windows - Cleaned up WM_{,ICON}ERASEBACKGROUND default handling - Added some comments on how Windows behaves --- windows/defwnd.c | 28 +++++++++------------------- windows/painting.c | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/windows/defwnd.c b/windows/defwnd.c index f40176c4d49..13d8c2da6f2 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -21,9 +21,6 @@ DEFAULT_DEBUG_CHANNEL(win) - /* Last COLOR id */ -#define COLOR_MAX COLOR_GRADIENTINACTIVECAPTION - /* bits in the dwKeyData */ #define KEYDATA_ALT 0x2000 #define KEYDATA_PREVSTATE 0x4000 @@ -301,28 +298,21 @@ static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT msg, WPARAM wParam, case WM_ERASEBKGND: case WM_ICONERASEBKGND: { - RECT16 rect; + RECT rect; if (!wndPtr->class->hbrBackground) return 0; /* Since WM_ERASEBKGND may receive either a window dc or a */ /* client dc, the area to be erased has to be retrieved from */ /* the device context. */ - GetClipBox16( (HDC16)wParam, &rect ); - - if (wndPtr->class->hbrBackground <= (HBRUSH16)(COLOR_MAX+1)) - { - HBRUSH hbrush = CreateSolidBrush( - GetSysColor(((DWORD)wndPtr->class->hbrBackground)-1)); - PaintRect16( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf, - (HDC16)wParam, hbrush, &rect); - DeleteObject( hbrush ); - } - else - { - PaintRect16( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf, - (HDC16)wParam, wndPtr->class->hbrBackground, &rect ); - } + GetClipBox( (HDC)wParam, &rect ); + + /* Always call the Win32 variant of FillRect even on Win16, + * since despite the fact that Win16, as well as Win32, + * supports special background brushes for a window class, + * the Win16 variant of FillRect does not. + */ + FillRect( (HDC) wParam, &rect, wndPtr->class->hbrBackground); return 1; } diff --git a/windows/painting.c b/windows/painting.c index 98a90ac4807..677eaa96033 100644 --- a/windows/painting.c +++ b/windows/painting.c @@ -24,6 +24,9 @@ DECLARE_DEBUG_CHANNEL(nonclient) (r).right = (wnd)->rectClient.right - (wnd)->rectWindow.left; \ (r).bottom = (wnd)->rectClient.bottom - (wnd)->rectWindow.top + /* Last COLOR id */ +#define COLOR_MAX COLOR_GRADIENTINACTIVECAPTION + /* Last CTLCOLOR id */ #define CTLCOLOR_MAX CTLCOLOR_STATIC @@ -568,7 +571,7 @@ static void RDW_UpdateRgns( WND* wndPtr, HRGN hRgn, UINT flags, BOOL firstRecurs { DeleteObject( wndPtr->hrgnUpdate ); wndPtr->hrgnUpdate = 0; - goto OUT; + goto end; } } break; @@ -686,7 +689,7 @@ EMPTY: RDW_UpdateRgns( wnd, hRgn, flags, FALSE ); } -OUT: +end: /* Set/clear internal paint flag */ @@ -1228,6 +1231,10 @@ INT WINAPI ExcludeUpdateRgn( HDC hdc, HWND hwnd ) /*********************************************************************** * FillRect16 (USER.81) + * NOTE + * The Win16 variant doesn't support special color brushes like + * the Win32 one, despite the fact that Win16, as well as Win32, + * supports special background brushes for a window class. */ INT16 WINAPI FillRect16( HDC16 hdc, const RECT16 *rect, HBRUSH16 hbrush ) { @@ -1252,6 +1259,10 @@ INT WINAPI FillRect( HDC hdc, const RECT *rect, HBRUSH hbrush ) { HBRUSH prevBrush; + if (hbrush <= (HBRUSH) (COLOR_MAX + 1)) { + hbrush = GetSysColorBrush( (INT) hbrush - 1 ); + } + if (!(prevBrush = SelectObject( hdc, hbrush ))) return 0; PatBlt( hdc, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top, PATCOPY ); -- 2.11.4.GIT