How to change the printer in FR ?

王朝other·作者佚名  2006-01-09
宽屏版  字体: |||超大  

Q:

I can get the printer(s) List by using Delphi 6 Pro as the following code.

uses

printers

ComboBox1.Items.Assign(Printer.Printers);

But, I don't know how to change the properity of a frReport for the user selection!

The default printer selection dialog cannot be made a filter for our need ( e.g. print to a Fax printer, PDF printer, PostScript enabled printer or Dot-Martix printer ).

Would you give me some advice ?

A:

Use the TFRReport.ChangePrinter(OldIndex,NewInde:Integer):Boolean

function to change the output printer without using any customizable

printer setting dialogs. The parameters are the same as the reference

indexes in the Printer.Printers array. My preferred way to implement

this on the GUI: populate a combobox with the Printer.Printers list and

then let the user choose one from the list.

So:

Uses System,....,...,Printers;

YourForm.OnCreate(Sender:TObject);

Begin

PrinterCombo.Items.Assign(Printer.Printers);

End;

TYourForm.PrintButtonClick(Sender:TObject);

Begin

Report.LoadFromFile(...);

Report.ChangePrinter(-1, PrinterCombo.ItemIndex);

Report.Prepare;

...etc.

End;

-1 for the OldIndex parameter cause the report to use the original

index, so You don't need to know the previous index.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有