• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Print a Control to an Image and Copy to ClipBoard??

I'm having some dificulty following the way Delphi prints and uses the clipboard. I am trying to do the following:

1. Print a control to an image.
2. Copy that image (in whatever format) to clipboard.

In Visual Basic it works like this:

myControl.PrinterHDC = Picture1.hDC
Picture1.Refresh
Clipboard.Clear
Clipboard.SetData Picture1.Image

In Delphi I have been trying to use the Image1.Canvas.Handle, but have not been able to get it to work.

Any help would be greatly appreciated.

Sincerely,

-S
0
summerset
Asked:
summerset
  • 2
1 Solution
 
ThaddyCommented:
if the control in question is just a form, you can use getformimage to obtain a bitmap representation of the form in  a Timage, and use copytoclipboard or assign to put it there
procedure TForm1.Button1Click(Sender: TObject);

var
  FormImage: TBitmap;
begin
  FormImage := GetFormImage;
try
  Clipboard.Assign(FormImage);
  Image1.Picture.Assign(Clipboard);
finally
  FormImage.Free;
end;
end;


0
 
summersetAuthor Commented:
Works great! If I want to save the picture to a file...should I just save from the clipboard then?

-S
0
 
ThaddyCommented:
You can just 'savetofile' from the Timage.picture.
See the onlne help on Tpicture. You might find even more that you like...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now