Solved

Capture The ScreenOutLook?

Posted on 1997-07-02
1
203 Views
Last Modified: 2010-04-06
How do I capture the picture of the whole screen in a certain moment into, for example, a bitmap-file?
Is it possible?
/Per
0
Comment
Question by:PerBoman
[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
1 Comment
 
LVL 1

Accepted Solution

by:
fsanchez earned 100 total points
ID: 1338069
This function works in 32 bits. It returns the handle of one bitmap that contains the desktop image. You can assign it to an existing TBitmap this way:
  Bitmap.Handle := GetScreenBitmapHandle;

If you don't do this, then you should call DeleteObject(YourBitmapHandle) after working with it.

function GetScreenBitmapHandle: HBITMAP;
var
  hdcScreen,
  hdcCompatible: HDC;
  hbmScreen: HBITMAP;
  Width, Height: Integer;
begin
  Result := 0;
  hdcScreen := CreateDC('DISPLAY', nil, nil, nil);
  if hdcScreen <> 0 then
  begin
    hdcCompatible := CreateCompatibleDC(hdcScreen);
    if hdcCompatible <> 0 then
    begin
      Width  := GetDeviceCaps(hdcScreen, HORZRES);
      Height := GetDeviceCaps(hdcScreen, VERTRES);
      hbmScreen := CreateCompatibleBitmap(hdcScreen, Width, Height);
      if hbmScreen <> 0 then
      begin
        if SelectObject(hdcCompatible, hbmScreen) <> GDI_ERROR then
        begin
          if BitBlt(hdcCompatible, 0, 0, Width, Height, hdcScreen, 0, 0,
               SRCCOPY) then
            Result := hbmScreen;
        end;
      end;
      DeleteDC(hdcCompatible);
    end;
    DeleteDC(hdcScreen);
  end;
end;

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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