如何在使用Quick report的程序中设置打印机,选择打印机 如何在使用Quick report的程序中设置打印机,选择打印机 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Quick report,打开时有的呀 unit chprin;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,PRINTERS, StdCtrls;type TForm1 = class(TForm) Button1: TButton; ComboBox1: TComboBox; Button2: TButton; Button3: TButton; PrintDialog1: TPrintDialog; PrinterSetupDialog1: TPrinterSetupDialog; procedure Button1Click(Sender: TObject); procedure ComboBox1Change(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var Device: array[0..255] of Char; Driver: array[0..255] of char; Port: array[0..255] of char; s : array[0..255] of Char; hDeviceMode: THandle;begin //messagebeep(2); beep(); Printer.PrinterIndex := ComboBox1.ItemIndex; Printer.GetPrinter (Device, Driver, Port, hDeviceMode); StrCopy (s, Device); StrCat (s, ','); StrCat (s, Driver); StrCat (s, ','); StrCat (s, Port); WriteProfileString ('windows', 'device', s); StrCopy (s, 'windows'); SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@s)); ComboBox1.Items := Printer.Printers; {populates ComboBox} ComboBox1.ItemIndex := Printer.PrinterIndex; end;procedure TForm1.ComboBox1Change(Sender: TObject);var Device: array[0..255] of Char; Driver: array[0..255] of char; Port: array[0..255] of char; s : array[0..255] of Char; hDeviceMode: THandle;begin Printer.PrinterIndex := ComboBox1.ItemIndex; Printer.GetPrinter (Device, Driver, Port, hDeviceMode); StrCopy (s, Device); StrCat (s, ','); StrCat (s, Driver); StrCat (s, ','); StrCat (s, Port); WriteProfileString ('windows', 'device', s); StrCopy (s, 'windows'); SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@s));end;将此程序放在QUICKREP打印之前执行即可选择打印机。 access violation错误 cxgrid如何默认模糊过滤? unti1如何调用unit2中自定义的函数! 如何将tFont存入数据库? 如何控制媒体播放的窗口? 甩分啦,请教高手,如何用delphi来获取公网ip?? 这段代码怎么写? 向高手寻求仿 ODAC NET 的组件原理的源程序!! 请教一下,如何实现三折线的中间一条线的选择??改变三折线的位置, MIS开发_关于组织结构的问题 连接远程sql server怎么出问题呢? RichEdit中如何加上点击可直接打开浏览器上网,(类似IE或者OICQ)
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,PRINTERS, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
Button2: TButton;
Button3: TButton;
PrintDialog1: TPrintDialog;
PrinterSetupDialog1: TPrinterSetupDialog;
procedure Button1Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
Device: array[0..255] of Char;
Driver: array[0..255] of char;
Port: array[0..255] of char;
s : array[0..255] of Char;
hDeviceMode: THandle;begin
//messagebeep(2);
beep();
Printer.PrinterIndex := ComboBox1.ItemIndex;
Printer.GetPrinter (Device, Driver, Port, hDeviceMode);
StrCopy (s, Device);
StrCat (s, ',');
StrCat (s, Driver);
StrCat (s, ',');
StrCat (s, Port);
WriteProfileString ('windows', 'device', s);
StrCopy (s, 'windows');
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@s));
ComboBox1.Items := Printer.Printers; {populates ComboBox}
ComboBox1.ItemIndex := Printer.PrinterIndex;
end;procedure TForm1.ComboBox1Change(Sender: TObject);
var
Device: array[0..255] of Char;
Driver: array[0..255] of char;
Port: array[0..255] of char;
s : array[0..255] of Char;
hDeviceMode: THandle;begin Printer.PrinterIndex := ComboBox1.ItemIndex;
Printer.GetPrinter (Device, Driver, Port, hDeviceMode);
StrCopy (s, Device);
StrCat (s, ',');
StrCat (s, Driver);
StrCat (s, ',');
StrCat (s, Port);
WriteProfileString ('windows', 'device', s);
StrCopy (s, 'windows');
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@s));
end;
将此程序放在QUICKREP打印之前执行即可选择打印机。