Solved

capturing the whole screen

Posted on 1997-10-10
4
210 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

Free Trending Threat Insights Every Day

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

18 Experts available now in Live!

Get 1:1 Help Now