PrintToFile, Version 1.3c (alt)
Hinweis: dies ist nicht die neueste Version!
Datei: Sample/main.pas
{ main.pas This file is part of the PrintToFile.pas sample application. Info at http://flocke.vssd.de/prog/code/pascal/prt2file/ Copyright (C) 2005, 2006 Volker Siebert <flocke@vssd.de> All rights reserved. } unit main; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm1 = class(TForm) RichEdit1: TRichEdit; Edit1: TEdit; Label1: TLabel; Button3: TButton; GroupBox1: TGroupBox; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; Button1: TButton; SaveDialog1: TSaveDialog; PrinterSetupDialog1: TPrinterSetupDialog; Button2: TButton; procedure FormShow(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation uses WinSpool, Printers, PrintToFile; {$R *.dfm} procedure TForm1.Button3Click(Sender: TObject); var ok: boolean; Filename: string; Question: string; begin if GroupBox1.Enabled then begin if RadioButton1.Checked then ok := Patch_TPrinter_BeginDoc else if RadioButton2.Checked then ok := Patch_StartDoc_ImportTable else ok := Patch_StartDoc_DLL_Entry; if not ok then begin MessageDlg('The selected patch didn''t work!', mtInformation, [mbOk], 0); exit; end; GroupBox1.Enabled := false; end; Filename := Trim(Edit1.Text); PrintToThisFile := Filename; if Filename = '' then Question := 'Output will go to printer!' else Question := 'Output will go to file'#13#10 + Filename; if MessageDlg(Question + #13#10#13#10'Proceed?', mtConfirmation, [mbYes, mbNo], 0) <> mrYes then exit; RichEdit1.Print('Flocke''s PrintToFileTest'); if Filename <> '' then begin if MessageDlg('Done with printing!'#13#10#13#10 + 'Do you want to send it to the printer?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin if SendFileToPrinter(Filename, 'Flocke''s PrintToFileTest') then MessageDlg('File sent to printer!', mtInformation, [mbOk], 0) else MessageDlg('Something went wrong!', mtInformation, [mbOk], 0) end; end else MessageDlg('Done with printing!', mtInformation, [mbOk], 0); end; procedure TForm1.FormShow(Sender: TObject); begin RichEdit1.CaretPos := Point(0, 0); end; procedure TForm1.Button1Click(Sender: TObject); begin SaveDialog1.FileName := Trim(Edit1.Text); if SaveDialog1.Execute then Edit1.Text := SaveDialog1.FileName; end; procedure TForm1.Button2Click(Sender: TObject); begin PrinterSetupDialog1.Execute; end; end. |