root / UFPrevRap.pas
Historique | Voir | Annoter | Télécharger (3,854 ko)
1 |
unit UFPrevRap;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Forms, Classes, Controls, Messages, Dialogs, StdCtrls, Buttons, |
7 |
ExtCtrls, QuickRpt, QRPrntr; |
8 |
|
9 |
type
|
10 |
TQRPrevRapInterface = class(TQRPreviewInterface)
|
11 |
public
|
12 |
function Show(AQRPrinter: TQRPrinter): TWinControl; override; |
13 |
function ShowModal(AQRPrinter: TQRPrinter): TWinControl; override; |
14 |
end;
|
15 |
TFPrevRap = class(TForm)
|
16 |
QRPRapport: TQRPreview; |
17 |
LBas: TPanel; |
18 |
BBPrint: TBitBtn; |
19 |
LPrinter: TLabel; |
20 |
CBPrinter: TComboBox; |
21 |
LPage: TLabel; |
22 |
SBPrev: TSpeedButton; |
23 |
SBNext: TSpeedButton; |
24 |
PPage: TPanel; |
25 |
procedure FormShow(Sender: TObject);
|
26 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
27 |
procedure BBPrintClick(Sender: TObject);
|
28 |
procedure CBPrinterChange(Sender: TObject);
|
29 |
procedure SBPrevClick(Sender: TObject);
|
30 |
procedure SBNextClick(Sender: TObject);
|
31 |
procedure QRPRapportPageAvailable(Sender: TObject; PageNum: Integer);
|
32 |
procedure FormCreate(Sender: TObject);
|
33 |
procedure WMSysCommand(var Mess: TWMSysCommand); message WM_SYSCOMMAND; |
34 |
private
|
35 |
{ D?clarations priv?es }
|
36 |
public
|
37 |
{ D?clarations publiques }
|
38 |
constructor CreatePreview(AOwner: TComponent; AQRPrinter: TQRPrinter); virtual; |
39 |
end;
|
40 |
|
41 |
var
|
42 |
FPrevRap: TFPrevRap; |
43 |
|
44 |
implementation
|
45 |
|
46 |
uses
|
47 |
Printers, SysUtils, gnugettext, UStrings, UUtil; |
48 |
|
49 |
{$R *.dfm}
|
50 |
|
51 |
{TQRPrevRapInterface}
|
52 |
|
53 |
function TQRPrevRapInterface.Show(AQRPrinter: TQRPrinter): TWinControl;
|
54 |
begin
|
55 |
Result := TFPrevRap.CreatePreview(Self, AQRPrinter); |
56 |
TFPrevRap(Result).Show; |
57 |
end;
|
58 |
|
59 |
function TQRPrevRapInterface.ShowModal(AQRPrinter: TQRPrinter): TWinControl;
|
60 |
begin
|
61 |
Result := TFPrevRap.CreatePreview(Self, AQRPrinter); |
62 |
TFPrevRap(Result).ShowModal; |
63 |
end;
|
64 |
|
65 |
{TFPrevRap}
|
66 |
|
67 |
constructor TFPrevRap.CreatePreview(AOwner: TComponent; AQRPrinter: TQRPrinter);
|
68 |
begin
|
69 |
inherited Create(AOwner);
|
70 |
QRPRapport.QRPrinter := AQRPrinter; |
71 |
end;
|
72 |
|
73 |
procedure TFPrevRap.FormCreate(Sender: TObject);
|
74 |
begin
|
75 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
76 |
then
|
77 |
Font.Name := 'Arial Unicode MS';
|
78 |
TranslateComponent(Self); |
79 |
end;
|
80 |
|
81 |
procedure TFPrevRap.FormClose(Sender: TObject; var Action: TCloseAction); |
82 |
begin
|
83 |
QRPRapport.QRPrinter.ClosePreview(Self); |
84 |
Application.ProcessMessages; |
85 |
Action := caFree; |
86 |
end;
|
87 |
|
88 |
|
89 |
procedure TFPrevRap.FormShow(Sender: TObject);
|
90 |
begin
|
91 |
BBPrint.Enabled := IsComplete or IsEducation ;
|
92 |
CBPrinter.Items.Assign(Printer.Printers); |
93 |
CBPrinter.ItemIndex := Printer.PrinterIndex; |
94 |
end;
|
95 |
|
96 |
procedure TFPrevRap.QRPRapportPageAvailable(Sender: TObject;
|
97 |
PageNum: Integer); |
98 |
begin
|
99 |
with QRPRapport do |
100 |
LPage.Caption := Format(StrPage, [PageNumber, PageNum]); |
101 |
end;
|
102 |
|
103 |
procedure TFPrevRap.BBPrintClick(Sender: TObject);
|
104 |
var
|
105 |
oldQRPrinter: TQRPrinter; |
106 |
begin
|
107 |
oldQRPrinter := QRPRapport.QRPrinter; |
108 |
TQuickRep(QRPRapport.QRPrinter.ParentReport).Print; |
109 |
QRPRapport.QRPrinter := oldQRPrinter; |
110 |
end;
|
111 |
|
112 |
procedure TFPrevRap.CBPrinterChange(Sender: TObject);
|
113 |
begin
|
114 |
Printer.PrinterIndex := CBPrinter.ItemIndex; |
115 |
TCustomQuickRep(QRPRapport.QRPrinter.ParentReport).PrinterSettings.PrinterIndex := Printer.PrinterIndex; |
116 |
end;
|
117 |
|
118 |
procedure TFPrevRap.SBPrevClick(Sender: TObject);
|
119 |
begin
|
120 |
with QRPRapport do |
121 |
if PageNumber > 1 |
122 |
then
|
123 |
PageNumber := PageNumber - 1
|
124 |
else
|
125 |
Beep; |
126 |
with QRPRapport do |
127 |
LPage.Caption := Format('Page %d / %d', [PageNumber, QRPrinter.PageCount]);
|
128 |
end;
|
129 |
|
130 |
procedure TFPrevRap.SBNextClick(Sender: TObject);
|
131 |
begin
|
132 |
with QRPRapport do |
133 |
if PageNumber < QRPrinter.PageCount
|
134 |
then
|
135 |
PageNumber := PageNumber + 1
|
136 |
else
|
137 |
Beep; |
138 |
with QRPRapport do |
139 |
LPage.Caption := Format('Page %d / %d', [PageNumber, QRPrinter.PageCount]);
|
140 |
end;
|
141 |
|
142 |
procedure TFPrevRap.WMSysCommand(var Mess: TWMSysCommand); |
143 |
begin
|
144 |
if Mess.CmdType = SC_MINIMIZE
|
145 |
then
|
146 |
Application.Minimize |
147 |
else
|
148 |
inherited;
|
149 |
end;
|
150 |
|
151 |
end.
|