Got ya this time. BTW that should have worked but anyway.
Put the Following in your form create
This copies the screen to your Image1 in the size of your form.
Look at BitBlt in the Online Help to understand what is going on.
procedure TForm1.FormCreate(Sender: TObject);
var
ScreenBit : TBitmap;
ScreenDC : HDC;
begin
ScreenBit := TBitmap.Create;
Image1.Picture.Graphic := ScreenBit;
Image1.Picture.Graphic.Width := Form1.ClientWidth;
Image1.Picture.Graphic.Height := Form1.ClientHeight;
ScreenDC := GetDC(0);
BitBlt(Image1.Picture.Bitmap.Canvas.Handle, 0,0, Form1.ClientWidth,
Form1.ClientHeight, ScreenDC, 0,0, SRCCOPY);
ReleaseDC(0, ScreenDC);
ScreenBit.Free;
end;
Cheers
Jim
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 7 June 2000 15:51
To: Multiple recipients of list delphi
Subject: [DUG]: Copy Screen to Clipboard - saga!
> Yeah. I meant to put GetWindowsDC in not GetDC.
>
> I'm not sure I understand exactly what your after.
> If you want to trap the entire screen just go
>
> theDC := GetDC(0);
> Image1.Canvas.Handle := theDc;
>
> If that doesn't work or not what your after give me a yell.
>
Well it sounds as though this is what I am after, but it doesn't work. (I
changed the line to GetWindowsDC(0) but it doesn't know that... took
GetWindowDC
(0) OK but the TImage didn't have anything in it when the form came back.
Here's the section of code - perhaps I've misunderstood how to use it.
procedure TForm1.GetScreen1Click(Sender: TObject);
Var
theDC : HDC;
begin
Form1.Visible := false;
theDC := GetWindowDC(0);
Image1.Canvas.Handle := theDC
Form1.Visible := true;
end;
As you can see, I'm trying to get the form out of the way to display what is
on
the screen underneath, then calling GetWindowDC(0) and then making the form
visible again.
I want the form to come back up with a copy of the desktop or whatever other
application is running underneath showing in the TImage.
As I said, I can press the printscreen key manually before running the
program
then use ASSIGN method to get the image into the TIMage and that works fine
-
just can't do it from the program yet...
Laurie..
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
CAUTION - This message may contain privileged and confidential information intended
only for the
use of the addressee(s) named above. If you are not the intended recipient of this
message you are
hereby notified that any use, dissemination, distribution or reproduction of this
message is prohibited.
If you have received this message in error please notify Progressive Enterprises Ltd.
immediately via
email at [EMAIL PROTECTED] Any views expressed in this message
are those of the
individual sender and may not necessarily reflect the views of Progressive Enterprises
Ltd.
This footnote also confirms that Progressive Enterprises Ltd. has swept this email
message for the
presence of computer viruses. This does not guarantee this message is virus free.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz