Solved

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

Posted on 1998-10-14
3
353 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now