Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

KneeBreaker (Programmer)
28 Dec 98 11:31
I am new to DELPHI and cannot seem to find how to print the contents of a screen using a button to activate the process. Any help would be appreciated.
qados (Programmer)
7 Apr 99 9:09
I'm also looking for an answer to this question, one piece of information I've found is for a little delphi program that "magnifies" a section of the desktop screen. I havn't really studied this yet, but I figure that in order to magnify part of the screen you must have to capture it in some way.

If I can figure out anything I'll let you know - otherwise I hope this can start to shed some light!

The URL below is the page I was looking at for this piece of delphi code.

http://delphi.miningco.com/library/weekly/aa120198.htm?rf=dp&COB=home
Roundley (MIS)
16 May 99 21:31
Head over to www.torry.ru and poke through the huge collection of delphi components, applications and samples there--you are bound to find something (everything!) you need.

:o)
qados (Programmer)
8 Jun 99 7:37
Thanks for the tip Tim, I managed to find a couple of programs that accessed the desktop at the URL you gave, it actually turned out to be quite easy...

Create a new project, and place a button on the form, double click it to create a new procedure and then cut and paste in the procedure I have included below.

{ START OF SCREEN PRINTING PROCEDURE }
procedure TForm1.Button1Click(Sender: TObject);

var
DesktopDC: hDC;
DesktopCanvas: TCanvas;
DesktopRect: TRect;
ScreenShot : Tbitmap;

begin

{ Create the ScreenShot 'bitmap object' }
ScreenShot := TBitmap.create;

{ This is a Windows API function that can be used to permit painting anywhere in a window, see Win32 API help for more details}
DesktopDC := GetWindowDC( GetDesktopWindow );

{ Creating a canvas which will contain our 'desktop' }
DesktopCanvas := TCanvas.Create;
try
DesktopCanvas.Handle := DesktopDC;

{ Creating a rectangle that is the size of the screen}
DeskTopRect := Rect(0,0,Screen.Width,Screen.Height);

{ Now we can set up our 'bitmap object' to the correct dimensions }
ScreenShot.Width :=DeskTopRect.Right-DeskTopRect.Left;
ScreenShot.Height:=DeskTopRect.Bottom-DeskTopRect.Top;

{ This function copies a rectangular image from one canvas to another, in our case from the 'desktop' canvas to our 'bitmap object' }
ScreenShot.Canvas.CopyRect( DeskTopRect,
DeskTopCanvas, DeskTopRect );

finally

{ Free up resources }
DesktopCanvas.Free;
ReleaseDC( GetDesktopWindow, DesktopDC );
end;

{ Save our bitmap to the disk }
ScreenShot.SaveToFile( 'c:\ScreenShot.bmp' );

end;
{ END OF SCREEN PRINTING PROCEDURE }


Just a quick note, some of the lines of code may have been split over two lines in your browser window... just use common sense to piece it back together. :)

This program should copy the desktop to the file name given in the code, but you can always change this so that it saves to a user specified file or something.

I hope this helps somewhat.

qados (Programmer)
8 Jun 99 7:39
Thanks for the tip Tim, I managed to find a couple of programs that accessed the desktop at the URL you gave, it actually turned out to be quite easy...

Create a new project, and place a button on the form, double click it to create a new procedure and then cut and paste in the procedure I have included below.

{ START OF SCREEN PRINTING PROCEDURE }
procedure TForm1.Button1Click(Sender: TObject);

var
DesktopDC: hDC;
DesktopCanvas: TCanvas;
DesktopRect: TRect;
ScreenShot : Tbitmap;

begin

{ Create the ScreenShot 'bitmap object' }
ScreenShot := TBitmap.create;

{ This is a Windows API function that can be used to permit painting anywhere in a window, see Win32 API help for more details}
DesktopDC := GetWindowDC( GetDesktopWindow );

{ Creating a canvas which will contain our 'desktop' }
DesktopCanvas := TCanvas.Create;
try
DesktopCanvas.Handle := DesktopDC;

{ Creating a rectangle that is the size of the screen}
DeskTopRect := Rect(0,0,Screen.Width,Screen.Height);

{ Now we can set up our 'bitmap object' to the correct dimensions }
ScreenShot.Width :=DeskTopRect.Right-DeskTopRect.Left;
ScreenShot.Height:=DeskTopRect.Bottom-DeskTopRect.Top;

{ This function copies a rectangular image from one canvas to another, in our case from the 'desktop' canvas to our 'bitmap object' }
ScreenShot.Canvas.CopyRect( DeskTopRect,
DeskTopCanvas, DeskTopRect );

finally

{ Free up resources }
DesktopCanvas.Free;
ReleaseDC( GetDesktopWindow, DesktopDC );
end;

{ Save our bitmap to the disk }
ScreenShot.SaveToFile( 'c:\ScreenShot.bmp' );

end;
{ END OF SCREEN PRINTING PROCEDURE }


Just a quick note, some of the lines of code may have been split over two lines in your browser window... just use common sense to piece it back together. :)

This program should copy the desktop to the file name given in the code, but you can always change this so that it saves to a user specified file or something.

I hope this helps somewhat.

qados (Programmer)
8 Jun 99 7:42
opps for the double sumission, I thought my first one had timed out :) DOH !

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close