Solved

Screenshot of desktop

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
problem when i try to pack my dll file with upx 9 71
Delphi cmd execution 6 55
Using idhttp to login to instagram 2 75
Delphi inherited method 6 60
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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

10 Experts available now in Live!

Get 1:1 Help Now