2022-10-12 20:24:11 +00:00
|
|
|
unit dvMain;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
2022-10-13 10:28:16 +00:00
|
|
|
Spin, PrintersDlgs, VpBaseDS, VpIniDs, VpDayView, VpPrtPrvDlg, VpPrtFmtCBox,
|
|
|
|
VpData;
|
2022-10-12 20:24:11 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
TForm1 = class(TForm)
|
|
|
|
btnPrintPreview: TButton;
|
|
|
|
btnPrint: TButton;
|
|
|
|
Label1: TLabel;
|
|
|
|
Panel1: TPanel;
|
|
|
|
PrintDialog1: TPrintDialog;
|
|
|
|
SpinEdit1: TSpinEdit;
|
|
|
|
VpControlLink1: TVpControlLink;
|
|
|
|
VpDayView1: TVpDayView;
|
|
|
|
VpIniDatastore1: TVpIniDatastore;
|
|
|
|
VpPrintFormatComboBox1: TVpPrintFormatComboBox;
|
|
|
|
VpPrintPreviewDialog1: TVpPrintPreviewDialog;
|
|
|
|
procedure btnPrintPreviewClick(Sender: TObject);
|
|
|
|
procedure btnPrintClick(Sender: TObject);
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure SpinEdit1Change(Sender: TObject);
|
|
|
|
private
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Form1: TForm1;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
|
|
|
uses
|
|
|
|
Printers;
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
procedure TForm1.btnPrintPreviewClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
d1, d2: TDateTime;
|
|
|
|
begin
|
|
|
|
d1 := EncodeDate(2022, 10, 1);
|
|
|
|
d2 := EncodeDate(2022, 10, 31);
|
|
|
|
VpPrintPreviewDialog1.StartDate := d1;
|
|
|
|
VpPrintPreviewDialog1.EndDate := d2;
|
|
|
|
if VpPrintPreviewDialog1.Execute then
|
|
|
|
if PrintDialog1.Execute then begin
|
|
|
|
Printer.BeginDoc;
|
|
|
|
try
|
|
|
|
VpPrintPreviewDialog1.ControlLink.Printer.Print(Printer, d1, d2);
|
|
|
|
finally
|
|
|
|
Printer.EndDoc;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.btnPrintClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
d1, d2: TDateTime;
|
|
|
|
begin
|
|
|
|
d1 := EncodeDate(2022, 10, 1);
|
|
|
|
d2 := EncodeDate(2022, 10, 31);
|
|
|
|
Printer.BeginDoc;
|
|
|
|
try
|
|
|
|
VpControlLink1.Printer.Print(Printer, d1, d2);
|
|
|
|
finally
|
|
|
|
Printer.EndDoc;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.FormCreate(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if VpIniDatastore1.Resources.Count > 0 then
|
|
|
|
VpIniDatastore1.Resource := VpIniDatastore1.Resources.Items[0];
|
|
|
|
VpDayView1.Date := EncodeDate(2022, 10, 1);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.SpinEdit1Change(Sender: TObject);
|
|
|
|
begin
|
|
|
|
VpDayView1.NumDays := SpinEdit1.Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|