Solved

Print Screen

Posted on 1998-12-01
8
263 Views
Last Modified: 2010-04-04
Hi
How do I do a Print Screen and also printing all active child windows at a time

VSP
0
Comment
Question by:v_pasupuleti
[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
  • 4
  • 4
8 Comments
 

Author Comment

by:v_pasupuleti
ID: 1348779
Edited text of question
0
 

Author Comment

by:v_pasupuleti
ID: 1348780
Adjusted points to 100
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1348781
Hi v,

Well try this,

procedure TForm1.Button1Click(Sender: TObject);
var
  DeskTop: TCanvas;
begin
  DeskTop := TCanvas.Create;
  try
    with DeskTop do Handle := GetWindowDC(GetDesktopWindow);
    Image1.BoundsRect := Desktop.ClipRect;
    with Image1.Canvas do
      CopyRect(Image1.BoundsRect, DeskTop, DeskTop.ClipRect)
  finally
    DeskTop.Free
  end;
  PrintImage;
end;

procedure TForm1.PrintImage;
var
  ScaleX, ScaleY: Integer;
  R  : TRect;
  Printer: TPrinter;
begin
  Printer := TPrinter.Create;
  try
    Printer.BeginDoc;
    with Printer do
    try
      ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
      ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
      R := Rect(0, 0, Image1.Picture.Width * ScaleX,
        Image1.Picture.Height * ScaleY);
      Canvas.StretchDraw(R, Image1.Picture.Graphic);
    finally
      EndDoc;
    end;
  except
    on E: Exception do showmessage(E.Message);
  end;
  Printer.Free;
end;

Just didn't have the change to test it on a printer yet, but it should get you going. It is a simple example of copying the desktop to an image and printing the image.

0
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!

 

Author Comment

by:v_pasupuleti
ID: 1348782
Thanks Bruintje,
It works.

Vijay
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1348783
Hmm...
Should I repost it as an answer?
0
 
LVL 44

Accepted Solution

by:
bruintje earned 100 total points
ID: 1348784
Well I do... :O)

procedure TForm1.Button1Click(Sender: TObject);
var
  DeskTop: TCanvas;
begin
  DeskTop := TCanvas.Create;
  try
    with DeskTop do Handle := GetWindowDC(GetDesktopWindow);
    Image1.BoundsRect := Desktop.ClipRect;
    with Image1.Canvas do
      CopyRect(Image1.BoundsRect, DeskTop, DeskTop.ClipRect)
  finally
    DeskTop.Free
  end;
  PrintImage;
end;

procedure TForm1.PrintImage;
var
  ScaleX, ScaleY: Integer;
  R  : TRect;
  Printer: TPrinter;
begin
  Printer := TPrinter.Create;
  try
    Printer.BeginDoc;
    with Printer do
    try
      ScaleX := GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
      ScaleY := GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
      R := Rect(0, 0, Image1.Picture.Width * ScaleX,
        Image1.Picture.Height * ScaleY);
      Canvas.StretchDraw(R, Image1.Picture.Graphic);
    finally
      EndDoc;
    end;
  except
    on E: Exception do showmessage(E.Message);
  end;
  Printer.Free;
end;

And goodluck...
0
 

Author Comment

by:v_pasupuleti
ID: 1348785
I accept it Bruintje, as a answer
Thanks again

Vijay
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1348786
My pleasure :O)
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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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