Vcl.Graphics.TPicture.LoadFromClipboardFormat

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle;  APalette: HPALETTE);

C++

void __fastcall LoadFromClipboardFormat(System::Word AFormat, NativeUInt AData, HPALETTE APalette);

Properties

Type Visibility Source Unit Parent
procedure
function
public
Vcl.Graphics.pas
Vcl.Graphics.hpp
Vcl.Graphics TPicture

Description

Reads the picture from the handle provided in the given Clipboard format.

Use LoadFromClipboardFormat to read in a graphic from the Clipboard. If the format is not supported, an EInvalidGraphic exception is raised.

The following code snippet shows how to load a picture from the clipboard into a TImage control.

Note: To load a picture into the clipboard, you can use the code snippet for the SaveToClipboardFormat method.

Delphi:

uses
  Vcl.Clipbrd;
procedure TForm1.Button1Click(Sender: TObject);
var
  Picture: TPicture;
begin
 Picture := TPicture.Create;
 try
   Picture.LoadFromClipboardFormat(cf_BitMap, ClipBoard.GetAsHandle(cf_Bitmap), 0);
   Image1.Picture := Picture;
 finally
   Picture.Free;
   Clipboard.Clear;
 end;
end;

C++:

#include <Vcl.Clipbrd.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender){
	TPicture* Picture;
	TClipboard* cb = Clipboard();

	Picture = new TPicture();
	try{
		Picture->LoadFromClipboardFormat(CF_BITMAP, cb->GetAsHandle(CF_BITMAP), 0);
		Image1->Picture = Picture;
	}
	__finally{
		delete Picture;
		cb->Clear();
	}
}

See Also