Commit 5fcd2039 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/button: Use duplicated image for drawing.

parent 38480c59
......@@ -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:
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment