procedure TForm1.HandleDIB( dataObj : IDataObject; fetc : TFormatEtc );
var
p : pointer;
stgm : TSTGMEDIUM;
BMIH : TBITMAPINFO;
bmp :HBITMAP;
_HDC, hDC : windows.HDC;
begin
{Make certain the data rendering is available}
if( dataObj.QueryGetData( fetc ) = NOERROR )
then
begin
{Get the data}
dataObj.GetData( fetc, stgm );
{Lock the global memory handle to get
a pointer to the data}
BMIH := TBITMAPINFO(GlobalLock(stgm.hGlobal)^);
with bmih.bmiHeader
do bmp:=CreateBitmap (biWidth,biHeight,biPlanes,biBitCount,@bmih.bmiColors);
_HDC := GetDC(Self.Handle);
hDC := CreateCompatibleDC(_HDC);
SelectObject(hDC, bmp);
BitBlt (hDC, 0, 0, bmih.bmiHeader.biWidth, bmih.bmiHeader.biHeight, img.Canvas.Handle, 0, 0, cmSrcCopy);
// Nur zum Füllen von bmp
BitBlt(_HDC, 0, 0, bmih.bmiHeader.biWidth, bmih.bmiHeader.biHeight, hDC, 0, 0, cmSrcCopy);
{Finished with the pointer}
GlobalFree( stgm.hGlobal );
{Free the memory}
ReleaseStgMedium( stgm );
end;
end;