Memo printing

Hi there,
I have got a memo... max 10 lines. I have 3 printers installed on the computer. How do I print the contents of the Memo to a specific printer quickly ?
LVL 1
drnadeemAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
intheConnect With a Mentor Commented:
Hi,

uses printers;

procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
printer.printerindex:= 1; //2 or 3
Printer.BeginDoc;
Printer.Canvas.Font.Style:= [fsBold, fsItalic];
Printer.Canvas.Font.Size:= 10;
for I := 0 to Memo1.Lines.Count -1 do
Printer.Canvas.TextOut(10, I * 100, Memo1.Lines[I]);
Printer.EndDoc;
end;

Regards Barry
0
 
aubsCommented:
Does it have to be a memo. If you change to a richedit, the is already a print method: richedit1.Print. Otherwise you will have to use the printer.canvas.textout method./

Toselect a particular printer

add printers to your uses clause

get the available printers from

printer.printers

assign the printer you want

printer.printerindex:= 1;

Regards

Aubs
0
 
drnadeemAuthor Commented:
How would I start to print the contents of the Memo after giving some blank lines from the top of the page ?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
intheCommented:
above doesnt work for that ?
if i press return 4-5 times in a memo then do :
showmessage(inttostr(memo1.lines.count));
on a button click then it shows me "4" or "5" so the loop in the print function should count them as lines also..
0
 
drnadeemAuthor Commented:
sorry barry,
I wanted to do that automatically by sending a line feed or enter key to the printer. I suppose there may be other ways like setting the caret position and then adding a blank line to the memo. In this case caret position should be right at the top of the memo.

any ideas ?
0
 
drnadeemAuthor Commented:
Got it barry,
Thanks... any better ideas appreciated!!

Memo1.Lines.Insert(0, '   ');
0
 
intheCommented:
Hi,
i think that is probably the quickest way what you have posted.
i can think of other ways using sendmessage but they take more than one line of code.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.