logik und deine suche ergibt keine treffer ^^
naja
Delphi-Quellcode:
uses
printers;
procedure TForm1.Button1Click(Sender: TObject);
var
I : Integer;
LineHeight : Integer;
LinesPerPage : Integer;
LineCount : Integer;
R : TRect;
S : string;
printer : Tprinter;
begin
printer:= TPrinter.Create;
if PrintDialog1.Execute then begin
Printer.Title := 'Notepad - ' + 'THE FILENAME';
Printer.Canvas.Font := Memo1.Font;
LineHeight := Abs(
MulDiv(Printer.Canvas.Font.Size,
GetDeviceCaps(Printer.Handle, LOGPIXELSY), 72));
Inc(LineHeight, (LineHeight * 4) div 10);
LinesPerPage := (Printer.PageHeight div lineHeight) - 4;
LineCount := 4;
Printer.BeginDoc;
R.Top := LineHeight;
R.Left := 30;
R.Right := Printer.PageWidth;
R.Bottom := LineHeight * 2;
DrawText(Printer.Handle,
PChar('THE FILENAME'), -1, R, DT_CENTER);
for I := 0 to Pred(Memo1.Lines.Count) do begin
Inc(LineCount);
if LineCount = LinesPerPage then begin
LineCount := 4;
Printer.NewPage;
end;
S := Memo1.Lines.Strings[I];
Printer.Canvas.TextOut(0, LineCount * LineHeight, S);
end;
Printer.EndDoc;
end;
printer.free;
end;
Quelle : Delphi Manager 2.0.0.6
Aber troztdem nächstes mal den Titel besser wählen