Solved

Print content of a TMemo.

Posted on 2001-08-15
3
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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