Solved

capturing the whole screen

Posted on 1997-10-10
4
212 Views
Last Modified: 2012-05-04
How do i capture the whole screen as a bitmap. i.e. what the equivalent of doing a print screen is to the clipboard, i want to do to a bitmap.  I've no experience outside of the client area. Thanks, Paul.
0
Comment
Question by:Heapster
  • 2
  • 2
4 Comments
 
LVL 1

Author Comment

by:Heapster
ID: 1347230
Adjusted points to 200
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1347231
Found this on uddf.

Capturing the DESKTOP to a form.canvas

From: Craig Francisco <Craig.Francisco@adm.monash.edu.au>

Try this:
-----------------------------------------------------------------

procedure TScrnFrm.GrabScreen;
 var

    DeskTopDC: HDc;
    DeskTopCanvas: TCanvas;
    DeskTopRect: TRect;
   
 begin
    DeskTopDC := GetWindowDC(GetDeskTopWindow);
    DeskTopCanvas := TCanvas.Create;
    DeskTopCanvas.Handle := DeskTopDC;

    DeskTopRect := Rect(0,0,Screen.Width,Screen.Height);

    ScrnForm.Canvas.CopyRect(DeskTopRect,DeskTopCanvas,DeskTopRect);

    ReleaseDC(GetDeskTopWindow,DeskTopDC);
end;

-----------------------------------------------------------------Note: I haven't tested this, so you may have to massage it a little. You may also have to play around with co-ordinates, depending on what you want to do. Also, if your form is already loaded and displayed, that is what you you will get, so you may want to do a hide and a show...

Have fun,
ZifNab;
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1347232
Well, changed the code a little bit and here is your answer :

procedure TForm1.GrabScreen;
 var
    DeskTopDC: HDc;
    DeskTopCanvas: TCanvas;
    DeskTopBitmap: TBitmap;
    DeskTopRect: TRect;

 begin
    DeskTopDC := GetWindowDC(GetDeskTopWindow);
    DeskTopCanvas := TCanvas.Create;
    DeskTopCanvas.Handle := DeskTopDC;
    DeskTopRect := Rect(0,0,Screen.Width,Screen.Height);
    DeskTopBitmap := TBitmap.Create;
   DeskTopBitmap.Canvas.CopyRect(DeskTopRect,DeskTopCanvas,DeskTopRect);
    Image1.Canvas.CopyRect(DeskTopRect,DeskTopCanvas,DeskTopRect);
    ReleaseDC(GetDeskTopWindow,DeskTopDC);
end;

Now you've got it in a bitmap (DeskTopBitmap) and you can see it on the screen (if you've put a Timage on the form)

Look out! You still have massage it to your needs, like width, height, and to hide the actual form. This isn't difficult :
Put Form1.Hide before you capture the screen and put Form1.Show after you've captured the screen.

Have fun,
ZifNab;
0
 
LVL 1

Author Comment

by:Heapster
ID: 1347233
Cheers, havent tested it yet, but looks the job. Nice One.Heap-I.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

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 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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

770 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