You've already forked lazarus-ccr
tvplanit: Add simple printing test projects
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8545 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
88
components/tvplanit/examples/printing/contacts/cgmain.pas
Normal file
88
components/tvplanit/examples/printing/contacts/cgmain.pas
Normal file
@@ -0,0 +1,88 @@
|
||||
unit cgMain;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
||||
Spin, PrintersDlgs, VpBaseDS, VpIniDs, VpDayView, VpPrtPrvDlg, VpPrtFmtCBox,
|
||||
VpContactGrid, VpContactButtons;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
btnPrintPreview: TButton;
|
||||
btnPrint: TButton;
|
||||
Panel1: TPanel;
|
||||
PrintDialog1: TPrintDialog;
|
||||
VpContactButtonBar1: TVpContactButtonBar;
|
||||
VpContactGrid1: TVpContactGrid;
|
||||
VpControlLink1: TVpControlLink;
|
||||
VpIniDatastore1: TVpIniDatastore;
|
||||
VpPrintFormatComboBox1: TVpPrintFormatComboBox;
|
||||
VpPrintPreviewDialog1: TVpPrintPreviewDialog;
|
||||
procedure btnPrintPreviewClick(Sender: TObject);
|
||||
procedure btnPrintClick(Sender: TObject);
|
||||
procedure FormCreate(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];
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user