Solved

Capture The ScreenOutLook?

Posted on 1997-07-02
1
193 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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