如何将TPrintDialog选择的系统打印机赋给TQuickRep? above 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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;以上为改变默认打印机,放入COMBOX即可。 在QUICKREP打印之前运行此程序即可选择不同打印机进行打印。 小诗一首 关于decimal字段的存储方式和算术运算性能的问题 急急急急急急,二叉數問題,在線等候... 如何让生成的报表在本窗体内预览 如何获得copyfile()的时间,现在想用progressbar显示copy的时间 光盘自动运行!! 本人过年做的一个Delphi Trace工具,免费下载试用! delphi中如何隐藏,系统中安装的一些程序在系统启动时,自动放置在系统托盘位置的图标? Delphi7 多表查询dbgrid不能更新显示 $150:请大家进来讨论“程序开发员的出路在哪里?以后应朝哪个方向发展?究竟该寻找什么样的奶酪!” dgrid的内容如何打印? 操作符的转换问题
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;
以上为改变默认打印机,放入COMBOX即可。