AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Memo Drucken

Ein Thema von TarantelFaser47 · begonnen am 30. Aug 2018 · letzter Beitrag vom 31. Aug 2018
Antwort Antwort
Benutzerbild von KodeZwerg
KodeZwerg

Registriert seit: 1. Feb 2018
3.691 Beiträge
 
Delphi 11 Alexandria
 
#1

AW: Memo Drucken

  Alt 31. Aug 2018, 09:03
Wie wäre es hiermit?
uses Printers;
Delphi-Quellcode:
procedure PrintStrings(Strings: TStrings);
var
  Prn: TextFile;
  i: word;
begin
  AssignPrn(Prn);
  try
    Rewrite(Prn);
    try
      for i := 0 to Strings.Count - 1 do
        writeln(Prn, Strings.Strings[i]);
    finally
      CloseFile(Prn);
    end;
  except
    on EInOutError do
      MessageDlg('Drucker nicht bereit.', mtError, [mbOk], 0);
  end;
end;
so in etwa Aufrufen:
  PrintStrings(Memo1.Lines);
Oder so:
Delphi-Quellcode:
// pack einen TPrintDialog und TButton auf Form
// hier wird Memo1 Font auch berücksichtigt, falls das eine Rolle spielt
procedure TForm1.Button1Click(Sender: TObject);
var
  MemoOutput: TextFile;
  I: LongInt;
begin
  If PrintDialog1.Execute then
   begin
     AssignPrn(MemoOutput); //assigns a text-file variable to the printer.
     try
       Rewrite(MemoOutput); //creates a new file and opens it
       try
         Printer.Canvas.Font := Memo1.Font; //Sets Font to Printer
         For I := 0 to Memo1.Lines.Count - 1 do
         WriteLn(MemoOutput, Memo1.Lines[I]); //puts it to the Printer Canvas
       finally
         CloseFile(MemoOutput); //terminates the association between file variable and an external disk file
       end;
     except
      on EInOutError do
       MessageDlg('Drucker nicht bereit.', mtError, [mbOk], 0);
     end;
   end;
end;
einen hab ich noch
Delphi-Quellcode:
procedure PrintMemo(const TheMemo: TMemo);
var
  MemoOutput: TextFile;
  I: LongInt;
begin
  If PrintDialog1.Execute then
   begin
     AssignPrn(MemoOutput); //assigns a text-file variable to the printer.
     try
       Rewrite(MemoOutput); //creates a new file and opens it
       try
         Printer.Canvas.Font := TheMemo.Font; //Sets Font to Printer
         For I := 0 to TheMemo.Lines.Count - 1 do
         WriteLn(MemoOutput, TheMemo.Lines[I]); //puts it to the Printer Canvas
       finally
         CloseFile(MemoOutput); //terminates the association between file variable and an external disk file
       end;
     except
      on EInOutError do
       MessageDlg('Drucker nicht bereit.', mtError, [mbOk], 0);
     end;
   end;
end;
Gruß vom KodeZwerg

Geändert von KodeZwerg (31. Aug 2018 um 09:45 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz