Vcl.Graphics.TBitmap.LoadFromClipboardFormat

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

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

C++

virtual 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 TBitmap

Description

Loads a bitmap from the Clipboard into the bitmap object.

LoadFromClipboardFormat is called if the bitmap is registered with the TPicture object using the RegisterClipboardFormat method.

LoadFromClipboardFormat replaces the current image with the data pointed to by the AData parameter. The palette for the bitmap is specified by the APalette parameter.

The following code snippet shows how to load a bitmap from the clipboard and use that picture to draw on the canvas of the form.

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

Delphi:

uses
  Vcl.Clipbrd;
procedure TForm1.Button1Click(Sender: TObject);
var
  Bitmap : TBitmap;
begin
 Bitmap := TBitMap.Create;
 try
   Bitmap.LoadFromClipBoardFormat(cf_BitMap, ClipBoard.GetAsHandle(cf_Bitmap), 0);
   Canvas.draw(0,0,Bitmap);
 finally
   Bitmap.Free;
   Clipboard.Clear;
 end;
end;

C++:

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

	Bitmap = new TBitmap();
	try{
		Bitmap->LoadFromClipboardFormat(CF_BITMAP, cb->GetAsHandle(CF_BITMAP), 0);
		Canvas->Draw(0,0,Bitmap);
	}
	__finally{
		delete Bitmap;
		cb->Clear();
	}
}

See Also

Code Examples