From 5fcd20396fb29a1f2ce87645cbb0d045ce5cf2d8 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 1 Apr 2020 15:17:50 +0300 Subject: [PATCH] comctl32/button: Use duplicated image for drawing. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47794 Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/button.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index 0078bd0fc61..b615df4a165 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -90,11 +90,12 @@ typedef struct _BUTTON_INFO HIMAGELIST glyph; /* this is a font character code when split_style doesn't have BCSS_IMAGE */ SIZE glyph_size; RECT text_margin; + HANDLE image; /* Original handle set with BM_SETIMAGE and returned with BM_GETIMAGE. */ union { HICON icon; HBITMAP bitmap; - HANDLE image; + HANDLE image; /* Duplicated handle used for drawing. */ } u; } BUTTON_INFO; @@ -488,6 +489,10 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L case WM_NCDESTROY: SetWindowLongPtrW( hWnd, 0, 0 ); + if (infoPtr->image_type == IMAGE_BITMAP) + DeleteObject(infoPtr->u.bitmap); + else if (infoPtr->image_type == IMAGE_ICON) + DestroyIcon(infoPtr->u.icon); heap_free(infoPtr->note); heap_free(infoPtr); break; @@ -859,13 +864,14 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L case BM_SETIMAGE: infoPtr->image_type = (DWORD)wParam; - oldHbitmap = infoPtr->u.image; - infoPtr->u.image = (HANDLE)lParam; - InvalidateRect( hWnd, NULL, FALSE ); - return (LRESULT)oldHbitmap; + oldHbitmap = infoPtr->image; + infoPtr->u.image = CopyImage((HANDLE)lParam, infoPtr->image_type, 0, 0, 0); + infoPtr->image = (HANDLE)lParam; + InvalidateRect( hWnd, NULL, FALSE ); + return (LRESULT)oldHbitmap; case BM_GETIMAGE: - return (LRESULT)infoPtr->u.image; + return (LRESULT)infoPtr->image; case BCM_SETIMAGELIST: {