Please enable JavaScript to view this site.

Codolex

Navigation: Activities > Clipboard

Read from clipboard

Scroll Prev Top Next More

The read from clipboard value can be used to get a string or an image from the clipboard

Uses Vcl.Clipbrd.TClipboard

 

By default a string is expected. To get an image, select the read image from clipboard option. This will result in a binary variable.

 

ImgFromClipboard

Activity properties

 

begin

var ClipBoardImage: ICodolexBinary;

var ClipBoard := TClipBoard.Create;

try

   ClipBoard.Open;

   

  var Image := TImage.Create(nil);

  var MemoryStream := TMemoryStream.Create;

  try

     ClipBoardImage := TCodolexBinary.Create;

    var Picture := Image.Picture;

    if ClipBoard.HasFormat(CF_PICTURE) then

    begin

       Picture.Assign(ClipBoard);

       Picture.SaveToStream(MemoryStream);

       ClipBoardImage.Stream.LoadFromStream(MemoryStream);

    end

    else if ClipBoard.HasFormat(CF_BITMAP) then

    begin

      var BitMap := Picture.BitMap;

       BitMap.Assign(ClipBoard);

       BitMap.SaveToStream(MemoryStream);

       ClipBoardImage.Stream.LoadFromStream(MemoryStream);

    end;

  finally

     Image.Free;

     MemoryStream.Free;

  end;

finally

   ClipBoard.Close;

   ClipBoard.Free;

end;

end;

 

 

 

© by GDK Software