Solved

Screenshot of desktop

Posted on 1998-12-11
5
273 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
[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
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

737 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