Solved

Capture The ScreenOutLook?

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now