?
Solved

Capture The ScreenOutLook?

Posted on 1997-07-02
1
Medium Priority
?
204 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 300 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

800 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