Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Print content of a TMemo.

Posted on 2001-08-15
3
Medium Priority
?
297 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 200 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

Technology Partners: 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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
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 anti-spam), the admin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

971 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