From: Oleh Nykyforchyn Subject: [PATCH] user16: Fix truncation for 16-bit handles. Message-Id: <20211025063121.14687-1-olen.nyk@gmail.com> Date: Mon, 25 Oct 2021 09:31:21 +0300 When background is erased in a 16 bit app, a handle to DC is passed through USER16 functions, namely CallWindowProc16 (USER.122) and DefDriverProc16 (USER.255), whose respective parameters are of type WPARAM16, hence the upper part of the handle is truncated. Later the returned handle is rejected by get_dc_attr() in GDI32 because its type is 0, although such handles are accepted by handle_entry(). This results in black and not cleared background. If handles are restored with HDC_32(), they pass get_dc_attr() successfully. Based on a patch by Nikolay Sivov. Supercedes https://source.winehq.org/patches/data/218030 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51899 Signed-off-by: Oleh Nykyforchyn --- dlls/user.exe16/message.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dlls/user.exe16/message.c b/dlls/user.exe16/message.c index 93e2cc018bf..eb1d957847a 100644 --- a/dlls/user.exe16/message.c +++ b/dlls/user.exe16/message.c @@ -899,6 +899,9 @@ LRESULT WINPROC_CallProc16To32A( winproc_callback_t callback, HWND16 hwnd, UINT1 case WM_SIZECLIPBOARD: FIXME_(msg)( "message %04x needs translation\n", msg ); break; + case WM_ERASEBKGND: + ret = callback( hwnd32, msg, (WPARAM)HDC_32(wParam), lParam, result, arg ); + break; default: ret = callback( hwnd32, msg, wParam, lParam, result, arg ); break; @@ -1670,6 +1673,14 @@ LRESULT WINAPI DefWindowProc16( HWND16 hwnd16, UINT16 msg, WPARAM16 wParam, LPAR case WM_GETTEXT: case WM_SETTEXT: return DefWindowProcA( hwnd, msg, wParam, (LPARAM)MapSL(lParam) ); + case WM_CTLCOLOR: + if (HIWORD(lParam) <= CTLCOLOR_STATIC) + return DefWindowProcA( hwnd, WM_CTLCOLORMSGBOX + HIWORD(lParam), + (WPARAM)HDC_32(wParam), (LPARAM)WIN_Handle32( LOWORD(lParam) ) ); + else + return 0; + case WM_ERASEBKGND: + return DefWindowProcA( hwnd, msg, (WPARAM)HDC_32(wParam), lParam ); default: return DefWindowProcA( hwnd, msg, wParam, lParam ); } -- 2.33.0