User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 402,632 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,299 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Dec 19th, 2004
Views: 3,773
This Delphi procedure sends the text contained in a multiline editbox (memo in Delphi lingo) to a printer. The font and font size can be specified.
delphi Syntax | 4 stars
  1. // send the lines of a multiline editbox (memo) to the printer
  2. // the form contains at least three components:
  3. // a Button, a MemoBox named TotalCost and a PrintDialog
  4. // note that BLANK is just a space character
  5. // Delphi 3.0
  6.  
  7. procedure TForm1.PrintTotalButtonClick(Sender: TObject);
  8. var
  9. POutput: TextFile;
  10. k: Integer;
  11. begin
  12. if PrintDialog1.Execute then
  13. begin
  14. AssignPrn(POutput);
  15. Rewrite(POutput);
  16. Printer.Canvas.Font.Name := 'Courier New';
  17. Printer.Canvas.Font.Size := 8;
  18. Writeln(POutput,BLANK);
  19. Writeln(POutput,BLANK);
  20. Writeln(POutput,BLANK);
  21. for k := 0 to TotalCost.Lines.Count - 1 do
  22. Writeln(POutput, ' ' + TotalCost.Lines[k]);
  23. CloseFile(POutput);
  24. end;
  25. end;
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 2:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC