Solved

Print Screen

Posted on 1998-12-01
8
258 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
 

Author Comment

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

Vijay
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

20 Experts available now in Live!

Get 1:1 Help Now