Solved

Capture The ScreenOutLook?

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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