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
Solved

capturing the whole screen

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Dbf export problem to a Visual Foxpro application 6 207
oracle global variables 4 76
Working with hours 3 65
FMX TEdit KeyUp handler detecting  "enter" key 4 13
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

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