Registriert seit: 27. Nov 2017
2.508 Beiträge
Delphi 7 Professional
|
AW: Wie man das Handle von einem Screenshot entfernt
9. Feb 2018, 16:02
You can get a Hardcopy using Method GetFormImage from TForm.
http://docwiki.embarcadero.com/CodeE...mImage_(Delphi)
Zitat von GetFormImage:
Description
This example uses an image, a button, and a shape component on a form. When you click the button, an image of the form is stored in the FormImage variable and copied to the Clipboard. The image of the form is then copied back to the image component, producing an interesting result, especially if the button is clicked multiple times. Add ExtCtrls, StdCtrls, and Clipbrd to the uses clause.
Delphi-Quellcode:
procedure HardCopy(sJpegFile : String; fm : TForm);
Var
FStream : TStream;
FBmp : TPicture;
FJpeg : TJpegImage;
begin
if SysUtils.FileExists(sJpegFile) then SysUtils.DeleteFile(sJpegFile);
FStream := TFileStream.Create(sJpegFile,fmCreate);
fm.WindowState := wsNormal;
fm.Show;
fm.Refresh;
FJpeg := TJpegImage.Create;
FBmp := TPicture.Create;
try
FBmp.Bitmap.Assign(fm.GetFormImage); // <- get a Hardcopy from TForm
FJpeg.Assign(FBmp.Bitmap);
FJpeg.SaveToStream(FStream);
finally
FStream.Free;
FJpeg.Free;
FBmp.Free;
end;
end;
Not tested:
Delphi-Quellcode:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,
Clipbrd;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
ScrollBox1: TScrollBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure ScreenShot(DestBitmap: TBitmap; fm : TForm);
begin
DestBitmap.Assign(fm.GetFormImage); // <- get a Hardcopy from TForm
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ScreenShot(Image1.Picture.Bitmap; Form1); // <-- or any other TForm
end;
end.
Geändert von Delphi.Narium ( 9. Feb 2018 um 18:19 Uhr)
|
|
Zitat
|