Printing from a TMemo

This should not be difficult but I am a bit retsricted on time at the moment so if someone can help me I would appreciate it tremendously. Hehe I used to have code doing this but have lost it with a drive crash. If someone has sample code for delphi 4 to print from a TMemo to a default printer, I will be very happy.
skymagAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TheNeilCommented:
Printer.BeginDoc;
Printer.Canvas.Font := Memo1.Font;

LineCount := 0;
LineHeight := Printer.Canvas.TextHeight('Aj');
FOR n := 0 TO Memo1.Lines.Count
DO
BEGIN
  Printer.TextOut(0, LineCount * LineHeight, Memo1.Lines[n]);
  LineCount := LineCount + 1;
  IF (LineCount * LineHeight) > Printer.PageHeight
  THEN
  BEGIN
    Printer.NewPage;
    LineCount := 0;
  END;
END;

Printer.EndDoc;

That'll do the job (assuming that you've got word wrap enabled on your Memo component)

The Neil
0
PeterLarsenCommented:
I think you ment "Printer.Canvas.TextOut". :-)
0
skymagAuthor Commented:
Thanx very much!

One small error:
Printer.TextOut(0, LineCount * LineHeight, Memo1.Lines[n]);
Should be:
Printer.Canvas.TextOut(0, LineCount * LineHeight, Memo1.Lines[n]);
 
0
TheNeilCommented:
Yeah I did. This wasn't cut and paste code it was typed straight in which explains why I missed it. At least you spotted it before using it

The Neil
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.