Solved

Screenshot of desktop

Posted on 1998-12-11
5
270 Views
Last Modified: 2010-04-04
i'll create a screenshot of the windows desktop.
i tried following code, but it's very slow.

 dc:=getdc($0000);
 for y := 0 to image1.picture.Bitmap.Height-1 do begin
  for x := 0 to image1.picture.Bitmap.Width-1 do
             image1.Canvas.Pixels[x,y]:=getpixel(dc,x,y);
  end;

{Bitmap.Height =1024
Bitmap.Width=768}

any idea how to make it faster
0
Comment
Question by:bqui
  • 3
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 20 total points
ID: 1350696
Hi bqui,

Try this

a form, a button, and a image,

procedure TForm1.Button1Click(Sender: TObject);
var
  DeskTop: TCanvas;
begin
  DeskTop := TCanvas.Create;
  try
    with DeskTop do Handle := GetWindowDC(GetDesktopWindow);
    Image1.BoundsRect := Desktop.ClipRect;
    with Image1.Canvas do
      CopyRect(Image1.BoundsRect, DeskTop, DeskTop.ClipRect)
  finally
    DeskTop.Free
  end;
end;

Good luck
Bruintje

0
 

Author Comment

by:bqui
ID: 1350697
i'll accept your answer,
but can you tell me first, why the screenshot is streched?
if not - ok -, anyway i'll give you the points
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1350698
Because you get a copy of the whole desktop window and so things like the the toolbars will get in the way of showing the whole desktop.

But you can prevent this and use the properties of the Desktop.cliprect (left, right etc) to solve this, by halving them and then assigning them to the (left, right etc) properties of Image1.

Hope this helps
Bruintje.

0
 

Author Comment

by:bqui
ID: 1350699
thank you
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1350700
my pleasure....
br(UINT)je.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 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