Solved

Screenshot of desktop

Posted on 1998-12-11
5
267 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 92
PHP preg_replace code convert to Delphi 14 57
enhance the following code 3 32
Firemonkey BASS_Init into a thread 17 9
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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