Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Print content of a TMemo.

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

670 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