Solved

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

Posted on 1998-10-14
3
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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