Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

capturing the whole screen

Posted on 1997-10-10
4
Medium Priority
?
218 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
[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
  • 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 600 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

647 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