Solved

Print Screen

Posted on 1998-12-01
8
262 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
  • 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
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.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

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