本文以實(shí)例說(shuō)明Delphi打印程序的實(shí)現(xiàn)方法。該實(shí)例可以檢測(cè)系統(tǒng)中安裝的所有打印機(jī),枚舉出這些打印機(jī),主要功能代碼非常簡(jiǎn)單,便于大家閱讀與理解。
主要功能代碼如下:
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,Printers, XPMan;type TForm1 = class(TForm) Button1: TButton; GroupBox1: TGroupBox; Memo1: TMemo; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin Memo1.Clear; memo1.Lines.Assign(Printer.Printers); if trim(memo1.Text) = '' then begin showmessage('沒(méi)有安裝打印機(jī)!'); end;end;procedure TForm1.Button2Click(Sender: TObject);begin Close;end;end.新聞熱點(diǎn)
疑難解答
圖片精選