Solved

Screenshot of desktop

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

17 Experts available now in Live!

Get 1:1 Help Now