...get a form as bitmap and copy it into the clipboard/ save it to a file?

Author: Chr. Schick

Category: Graphic

// Copy form1 as bitmap into the clipboard
// Kopiert Form1 als Bitmap in die Zwischenablage

procedure TForm1.Button1Click(Sender: TObject);
var
  
imgWindow: TBitmap;
begin
  
imgWindow := GetFormImage;
  try
    
Clipboard.Assign(imgWindow);
  finally
    
imgWindow.Free;
  end;
end;

// Save the bitmap to a file
// Das Bitmap in einer Datei speichern:

procedure TForm1.Button2Click(Sender: TObject);
var
  
imgWindow: TBitmap;
begin
  
imgWindow := TBitmap.Create;
  try
    
imgWindow := Form1.GetFormImage;
    imgWindow.SaveToFile('c:\FormImage.bmp');
  finally
    
imgWindow.Free;
  end;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base