首先我想知道您用的是不是鸟飞的2。0版,我在鸟飞的3。01版和4。0版上做了
测试,使用Tprintersetupdialog是可以改变默认的打印机输出。就我所知,鸟飞
的2。0版的Tprintersetupdialog存在您所说的问题。
如果您是使用鸟飞的2。0版我建议您升级到鸟飞的3。01版或4。0版以解决此问
题。
如您必须使用鸟飞的2。0版您可以参照以下程序定义一个Tprintersetupdialog
修改默认的打印机输出:
unit printerset;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,StdCtrls, ComCtrls, ExtCtrls,printers;
type
TForm1 = class(TForm)
PrinterSetupDialog1: TPrinterSetupDialog;
Button1: TButton;
ComboBox1: TComboBox;
Label1: TLabel;
Label2: TLabel;
RadioGroup1: TRadioGroup;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
printer.PrinterIndex:=combobox1.ItemIndex;
formcreate(self);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
printer.BeginDoc;
printer.Canvas.TextOut(10,20,'hello'+label1.Caption);
printer.EndDoc;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with combobox1 do
begin
Clear;
items.Assign(printer.Printers);
itemindex:=printer.PrinterIndex;
end;
label1.Caption:=printer.printers[printer.printerindex];
label2.Caption:='Width: '+Inttostr(printer.pageWidth)
label2.Caption:=label2.Caption+' Height: '+inttostr(Printer.PageHeight);
case printer.Orientation of
PoPortrait:RadioGroup1.ItemIndex:=0;
PoLandscape: RadioGroup1.ItemIndex:=1;
end;
end;
end.