Solved

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

Posted on 1998-10-14
3
355 Views
Last Modified: 2010-04-06
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
Comment
Question by:summerset
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
Thaddy earned 70 total points
ID: 1342838
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
 

Author Comment

by:summerset
ID: 1342839
Works great! If I want to save the picture to a file...should I just save from the clipboard then?

-S
0
 
LVL 2

Expert Comment

by:Thaddy
ID: 1342840
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question