Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PrntScr from Delphi vs MS Paint (which bypasses some thing) 2

Status
Not open for further replies.

ronkq

Programmer
Jul 10, 2010
13
US
.have a piece of Delphi (6,7,2010) code which does a screen capture to the Windows Clipboard, and prints a single sheet of the screen (1024x768) on any printer.
Problem: takes too long to get started printing vs MS Paint, which prints immediately.
How to achieve same thing in Delphi/PascaL.
Examination of the print queue - if using Delphi/ Windows normal print entry point; then the print queue fills with 50+ MB of data; if using MS Paint then the print queue fills with about 0.6MB. The Delphi program delivers about 0.7MB of data, but Windows blows it up to 50+MB depending on the printer. Applies to Win XP... Win 7.
What gives?.. What does MS Paint bypass, so that we can bypass that too?
Hope somebody can help.
Thank you for all efforts,
 
... seems this piece of code works...

unit PrtScr2U;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, Printers, Clipbrd;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
OpenClip1: TMenuItem;
procedure OpenClip1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.OpenClip1Click(Sender: TObject);
var Clp_img: TBitmap;
ClpRect: TRect;
PrtRect: TRect;
begin
Clp_Img := TBitmap.Create;
Clipboard.Open;
Clp_Img.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
ClpRect := Rect(0,0,Clp_Img.Width,Clp_Img.Height);
PrtRect := Rect(
printer.PageWidth div 20
,printer.PageHeight div 20
,printer.PageWidth-(printer.PageWidth div 10)
,printer.PageHeight-(printer.PageHeight div 10));
printer.BeginDoc;
printer.Canvas.CopyRect(PrtRect,Clp_Img.Canvas,ClpRect);
printer.EndDoc;
Clipboard.Close;
Clp_Img.Destroy
end;

end.

Looks like I had done waaayyy too much work...
Thank you for any further comments;
and for all previous dialog(s) and help,
RonkQ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top