win32: fix copying CF_BITMAP data into clipboard (bug #0012729)

git-svn-id: trunk@18309 -
This commit is contained in:
paul 2009-01-16 17:35:28 +00:00
parent 306e5ea3d4
commit 252c07b69b

View File

@ -635,6 +635,8 @@ function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
BufferWideString: widestring;
BufferString: ansistring;
{$ENDIF}
ScreenDC, MemDC: HDC;
OldBitmap, NewBitmap: HBitmap;
begin
DataStream := TMemoryStream.Create;
BufferStream := TMemoryStream.Create;
@ -645,10 +647,27 @@ function TWin32WidgetSet.ClipboardGetOwnerShip(ClipboardType: TClipboardType;
CF_BITMAP:
begin
Bitmap:= TBitmap.Create;
Bitmap.TransparentColor := clNone;
Bitmap.LoadFromStream(DataStream);
Windows.SetClipboardData(FormatID, Bitmap.Handle);
Bitmap.Free;
try
Bitmap.LoadFromStream(DataStream);
ScreenDC := GetDC(0);
try
MemDC := Windows.CreateCompatibleDC(ScreenDC);
NewBitmap := Windows.CreateCompatibleBitmap(ScreenDC, Bitmap.Width, Bitmap.Height);
OldBitmap := Windows.SelectObject(MemDC, NewBitmap);
StretchMaskBlt(MemDC, 0, 0, Bitmap.Width, Bitmap.Height,
Bitmap.Canvas.Handle, 0, 0, Bitmap.Width, Bitmap.Height,
Bitmap.MaskHandle, 0, 0, SRCCOPY);
Windows.SelectObject(MemDC, OldBitmap);
Windows.DeleteDC(MemDC);
Windows.SetClipboardData(FormatID, NewBitmap);
// GDI objects count does not vary if we delete it or not
// DeleteObject(NewBitmap);
finally
ReleaseDC(0, ScreenDC);
end;
finally
Bitmap.Free;
end;
end;
{$IFDEF WindowsUnicodeSupport}
Windows.CF_UNICODETEXT, Windows.CF_TEXT: