Solved

Print content of a TMemo.

Posted on 2001-08-15
3
286 Views
Last Modified: 2012-05-04
Hi,

What is the easiest way to print to contents of a memo-box (TMemo)?
When using a TRichEdit, you can use RichEdit1.Print('name'). However, this seems not to work with the TMemo component.

Thanx for helpin'

gr,.
RoosieDB
0
Comment
Question by:roosiedb
3 Comments
 
LVL 4

Accepted Solution

by:
fva earned 50 total points
ID: 6388393
I think this will work:

uses ...,Printers;

procedure PrintMemo(amemo:Tmemo);
var prf:TextFile;
begin
     AssignPrn(prf);
     Rewrite(prf);
     writeln(prf,amemo.Lines.Text);
     System.CloseFile(prf);
end;

F.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6388889
I found this out only last week:

procedure TForm1.Print1Click(Sender: TObject);
var
   i, iLine: Integer;
begin
     iLine := 0;
     If Not (PrintDialog.Execute) then Exit;

     Printer.BeginDoc;
     Try
     For i := 0 to Memo1.Lines.Count - 1 Do
     Begin
          {Font.Height is calculated as -Font.Size * 72 / Font.PixelsPerInch
          which returns a negative number, so Abs() is applied to the Height to
          make it a non-negative value. We add 12 just to get the spacing right}
          Printer.Canvas.TextOut(0, iLine, Memo1.Lines[i]);
          iLine := iLine + Abs(Printer.Canvas.Font.Height) + 12;
          If (iLine >= Printer.PageHeight) then Printer.NewPage;
     End;

     Finally
     Printer.EndDoc;
     End; {Try..Finally}
end;

J.
0
 

Author Comment

by:roosiedb
ID: 6403044
I guess both solutions provide me with the same results, however, fva brought me the most simple solution I was looking for. Thank you!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question