PostHeaderIconDelphi. Как копировать и вставлять Bitmap через буфер обмена?

function CopyClipToBuf(DC: HDC; Left, Top,
           Width, Height: Integer;  Rop: LongInt;
           var CopyDC: HDC;
           var CopyBitmap: HBitmap): Boolean;

var
  TempBitmap: HBitmap;

begin
  Result := False;
  CopyDC := 0;
  CopyBitmap := 0;
  if DC <> 0 then
    begin
      CopyDC := CreateCompatibleDC(DC);
      if CopyDC <> 0 then
        begin
          CopyBitmap := CreateCompatibleBitmap(DC,
                          Width, Height);
          if CopyBitmap <> 0 then
            begin
              TempBitmap := CopyBitmap;
              CopyBitmap := SelectObject(CopyDC,
                              CopyBitmap);
              Result := BitBlt(CopyDC, 0, 0,
                          Width, Height, DC,
                          Left, Top, Rop);
              CopyBitmap := TempBitmap;
            end;
        end;
    end;
end;

function CopyBufToClip(DC: HDC; var CopyDC: HDC;
           var CopyBitmap: HBitmap; 
           Left, Top, Width, Height: Integer;
           Rop: LongInt; DeleteObjects: Boolean): Boolean;

var
  TempBitmap: HBitmap;

begin
  Result := False;
  if (DC <> 0) and
     (CopyDC <> 0) and
     (CopyBitmap <> 0) then
    begin
      TempBitmap := CopyBitmap;
      CopyBitmap := SelectObject(DC, CopyBitmap);
      Result := BitBlt(DC, Left, Top,
                  Width, Height, CopyDC,
                  0, 0, Rop);
      CopyBitmap := TempBitmap;
      if DeleteObjects then
        begin
          DeleteDC(CopyDC);
          DeleteObject(CopyBitmap);
        end;
    end;
end;
 
Copyright © 2007-2010 IsIProg.ru. All Rights Reserved.