.


:




:

































 

 

 

 


Tprinter




 

TPrinter, . .

,
Canvas TCanvas. Canvas - , . Canvas , Pen () Brush (), .
TextOut Tcanvas, Canvas.
BeginDoc .
EndDoc . , EndDoc.  
PageHeight .
NewPage Pen Canvas (0, 0).
PageNumber .

 

,

, :

 

Printer.BeginDoc

Printer.Canvas.TextOut(10,10, '

Printer');

Printer.EndDoc;

 

' Printer', . BeginDoc . TextOut Canvas. EndDoc .

- , . . File2Prn.dpr File2Pob.dpr. FilePob.pas. , "" - Button2. , , , , .

9.2 . . FileObj.pas, "" (Button2) , 9.2. Caption, : " TPrinter".

 

9.2. Tprinter

_________

Unit FilepObj;

Interface

Uses

Windows, Messages, SysUtils, Classes, Graphics, Controls,

Forms, Dialogs, StdCtrls, Printers;

type

Tform1 = class (TForm)

Button1: TButton;

OpenDialog1: TOpenDialog;

Button2: TButton;

Label1: TLabel;

 

Procedure Button1Click(Sender: TObject);

Procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

 

var

Form1: Tform1;

 

Implementation

{$R *.DFM}

 

Var

Fname: String;

 

Procedure Tform1.Button1Click(Sender: TObject);

begin

if OpenDialog1.Execute then

begin

Fname: OpenDialog1.FileName;

Label1.Caption:= ' ' + Fname;

end;

end;

 

Procedure Tform1.Button2Click(Sender: TObject);

Var

F: TextFile;

TempStr, PageNum: String;

Ctr, x, PHeight, LineSpace: Integer;

begin

Ctr:= 1;

{ , }

AssignFile(F, Fname);

Reset;

{ }

Printer.BeginDoc;

{ }

Pheight:= Printer.PageHeight;

{ 60 }

LineSpace:= PHeight Div 60;

{ }

PageNum:= IntToStr(Printer.PageNumber);

{ }

Label1.Caption:= ' '+ Fname + ' '

+ PageNum;

 

While Not Eof(F) Do

begin

{ TempStr}

Readln(F, TempStr);

{ TempStr }

Printer.Canvas.TextOut(0, x, TempStr);

{ x

}

x:= x+LineSpace;

{ }

Ctr:= Ctr + 1;

{ 60 , ,

}

If Ctr > 59 then

begin

Printer.NewPage;

X:= 0;

Ctr:= 0;

PageNum:= IntToStr(Printer.PageNumber);

Label1.Caption:= ' '+ Fname +

' ' + PageNum;

end;

end;

 

( }

CloseFile(F);

Printer.EndDoc;

Labell.Caption:= ' !' + ' = '+ PageNum;

end;

 

end.

 

, , , . . , , .

. , , . . , .

 





:


: 2016-07-29; !; : 384 |


:

:

,
==> ...

1505 - | 1374 -


© 2015-2024 lektsii.org - -

: 0.013 .