Board index » delphi » Print file

Print file

How to print text file(I just have name of file and don't use richedit)?

Thanks.
Alex.

 

Re:Print file


Alex -

Open the file, read it, and write it out to the printer. If the file
is a reasonable Ascii file, that should work. If it's a specially
formatted file, that's a whole other can of worms, however.

Good luck.

Kurt

Re:Print file


Quote

> How to print text file(I just have name of file and don't use richedit)?

Alex,

if you want to keep your life simple and don't mind a little extra screen
activity, try this in a form method:

  ShellExecute( handle     { forms window handle },
                'print',   { action }
                Pchar(filename),  { file to print }
                Nil,       { no further parameters }
                Nil,       { no default dir, filename is full pathname }
                SW_HIDE );
  SetForegroundWindow( Handle );                

As long as filename is a file with a registered extension (e.g. .TXT or RTF
or DOC) this will call up the server application for this doc type and have
it print the document for you. The SW_HIDE may even keep this hidden from
the user.

Peter Below (TeamB)  100113.1...@compuserve.com)

Other Threads