Solved

Print content of a TMemo.

Posted on 2001-08-15
3
283 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now