[PATCH] comctl32/button: Use duplicated image for drawing.
Nikolay Sivov
nsivov at codeweavers.com
Wed Apr 1 07:17:50 CDT 2020
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47794
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
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 0078bd0fc6..b615df4a16 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:
{
--
2.25.1
More information about the wine-devel
mailing list