How to select the Printer at runtime?

Can I somehow change Report Options from my program? I have more than 1 printer and I want to have opportunity to change printer from my program - so I can save it to ini file or registry and I dont have to use Windows default printer or every time select printer I want. Yes I can save it in report, but thats not very good solution (thats not very user-friendly).

I have one solution, but it ###### ;) :
Before opening and printing that particular report:
- Save default printer to variable
- Load from ini or reg printer I want and set as default
After Printing report
- Set back default as default

Comments

  • edited 10:35AM
    The approximite code:
    uses printers,....
    ....
    ....
    ....
    var
    printer:TPrinter;
    index:integer;
    begin
    printer:= TPrinter.Create;
    printer.Printers;
    //ListBox1.Items:=printer.Printers;//if it is necessary possible to take list a printer
    index:=printer.PrinterIndex;//take current printer
    frReport1.ShowPrintDialog:=false;
    //we print 1-ouch report on 2 printer
    frReport1.LoadFromFile('rep1.frf');
    frReport1.ChangePrinter(index,2);//change printer with the current index on printer with index 2.
    frReport1.PrepareReport;
    frReport1.PrintPreparedReportDlg;
    //frReport1.PrintPreparedReport();//possible in the same way use this function
    //we print 2-ouch report on 3-m printer
    index:=printer.PrinterIndex;//take current printer
    frReport1.LoadFromFile('rep2.frf');
    frReport1.ChangePrinter(index,3);//change printer with the current index on printer with index 3.
    frReport1.PrepareReport;
    frReport1.PrintPreparedReportDlg;
    end;
    
  • edited 10:35AM
    thx buddy ;)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.