1 | unit UPrintPreview;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
---|
9 | ComCtrls, ExtCtrls, ActnList, PrintersDlgs, Contnrs, Printers, StdCtrls;
|
---|
10 |
|
---|
11 | const
|
---|
12 | ScreenDPI = 72;
|
---|
13 | SizeDivider = 7.2;
|
---|
14 |
|
---|
15 | type
|
---|
16 | TPrintPreviewForm = class;
|
---|
17 |
|
---|
18 | { TPrintPage }
|
---|
19 |
|
---|
20 | TPrintPage = class
|
---|
21 | Bitmap: TBitmap;
|
---|
22 | constructor Create;
|
---|
23 | destructor Destroy; override;
|
---|
24 | end;
|
---|
25 |
|
---|
26 | { TPrintPreview }
|
---|
27 |
|
---|
28 | TPrintPreview = class(TComponent)
|
---|
29 | private
|
---|
30 | FOnNewPage: TNotifyEvent;
|
---|
31 | FOnPrint: TNotifyEvent;
|
---|
32 | //FOnPrintFooter: TNotifyEvent;
|
---|
33 | FZoom: Double;
|
---|
34 | FPageNumber: Integer;
|
---|
35 | FPageCount: Integer;
|
---|
36 | function GetHeight: Integer;
|
---|
37 | function GetPageCount: Integer;
|
---|
38 | function GetPageNumber: Integer;
|
---|
39 | function GetWidth: Integer;
|
---|
40 | function GetXDPI: Integer;
|
---|
41 | function GetYDPI: Integer;
|
---|
42 | function GetZoom: Double;
|
---|
43 | procedure SetZoom(const AValue: Double);
|
---|
44 | procedure UpdateMargins;
|
---|
45 | public
|
---|
46 | Canvas: TCanvas;
|
---|
47 | Pages: TObjectList;
|
---|
48 | PageTitle: string;
|
---|
49 | Margins: TRect;
|
---|
50 | MarginsMM: TRect;
|
---|
51 | property XDPI: Integer read GetXDPI;
|
---|
52 | property YDPI: Integer read GetYDPI;
|
---|
53 | function MMToPixels(AValue: Double; VertRes: Boolean = True): Integer;
|
---|
54 | function PixelsToMM(AValue: Integer; VertRes: Boolean = True): Double;
|
---|
55 | procedure CreateNewPage;
|
---|
56 | constructor Create(AOwner: TComponent); override;
|
---|
57 | destructor Destroy; override;
|
---|
58 | procedure Preview;
|
---|
59 | procedure Execute;
|
---|
60 | procedure Print;
|
---|
61 | published
|
---|
62 | property PageNumber: Integer read GetPageNumber;
|
---|
63 | property Zoom: Double read GetZoom write SetZoom;
|
---|
64 | property OnNewPage: TNotifyEvent read FOnNewPage write FOnNewPage;
|
---|
65 | property OnPrint: TNotifyEvent read FOnPrint write FOnPrint;
|
---|
66 | property PageWidth: Integer read GetWidth;
|
---|
67 | property PageHeight: Integer read GetHeight;
|
---|
68 | property PageCount: Integer read GetPageCount;
|
---|
69 | end;
|
---|
70 |
|
---|
71 | { TPrintPreviewForm }
|
---|
72 |
|
---|
73 | TPrintPreviewForm = class(TForm)
|
---|
74 | AClose: TAction;
|
---|
75 | ALastPage: TAction;
|
---|
76 | AFirstPage: TAction;
|
---|
77 | ANextPage: TAction;
|
---|
78 | APreviousPage: TAction;
|
---|
79 | AZoomOut: TAction;
|
---|
80 | AZoomIn: TAction;
|
---|
81 | APageSetup: TAction;
|
---|
82 | APrinterSetup: TAction;
|
---|
83 | APrint: TAction;
|
---|
84 | ActionList1: TActionList;
|
---|
85 | Button1: TButton;
|
---|
86 | Button2: TButton;
|
---|
87 | Button3: TButton;
|
---|
88 | Button4: TButton;
|
---|
89 | EditPageNumber: TEdit;
|
---|
90 | Image1: TImage;
|
---|
91 | ImageList1: TImageList;
|
---|
92 | PageSetupDialog1: TPageSetupDialog;
|
---|
93 | PrintDialog1: TPrintDialog;
|
---|
94 | PrinterSetupDialog1: TPrinterSetupDialog;
|
---|
95 | ScrollBarHoriz: TScrollBar;
|
---|
96 | ScrollBarVert: TScrollBar;
|
---|
97 | ToolBar1: TToolBar;
|
---|
98 | ToolButton1: TToolButton;
|
---|
99 | ToolButton2: TToolButton;
|
---|
100 | ToolButton3: TToolButton;
|
---|
101 | ToolButton4: TToolButton;
|
---|
102 | ToolButton5: TToolButton;
|
---|
103 | ToolButton6: TToolButton;
|
---|
104 | ToolButton7: TToolButton;
|
---|
105 | ToolButton8: TToolButton;
|
---|
106 | ToolButton9: TToolButton;
|
---|
107 | procedure ACloseExecute(Sender: TObject);
|
---|
108 | procedure AFirstPageExecute(Sender: TObject);
|
---|
109 | procedure ALastPageExecute(Sender: TObject);
|
---|
110 | procedure ANextPageExecute(Sender: TObject);
|
---|
111 | procedure APageSetupExecute(Sender: TObject);
|
---|
112 | procedure APreviousPageExecute(Sender: TObject);
|
---|
113 | procedure APrinterSetupExecute(Sender: TObject);
|
---|
114 | procedure APrintExecute(Sender: TObject);
|
---|
115 | procedure AZoomInExecute(Sender: TObject);
|
---|
116 | procedure AZoomOutExecute(Sender: TObject);
|
---|
117 | procedure EditPageNumberChange(Sender: TObject);
|
---|
118 | procedure FormCreate(Sender: TObject);
|
---|
119 | procedure FormDestroy(Sender: TObject);
|
---|
120 | procedure FormResize(Sender: TObject);
|
---|
121 | procedure FormShow(Sender: TObject);
|
---|
122 | procedure ScrollBarHorizChange(Sender: TObject);
|
---|
123 | procedure ScrollBarVertChange(Sender: TObject);
|
---|
124 | private
|
---|
125 | FPrintPreview: TPrintPreview;
|
---|
126 | procedure ReloadPageNumber;
|
---|
127 | public
|
---|
128 | PageNumber: Integer;
|
---|
129 | procedure Redraw;
|
---|
130 | property PrintPreview: TPrintPreview read FPrintPreview
|
---|
131 | write FPrintPreview;
|
---|
132 | end;
|
---|
133 |
|
---|
134 | procedure Register;
|
---|
135 |
|
---|
136 | resourcestring
|
---|
137 | SPrintPreview = 'Print preview';
|
---|
138 | SPrint = 'Print';
|
---|
139 | SPageSetup = 'Page setup';
|
---|
140 | SPrinterSetup = 'Printer setup';
|
---|
141 | SClose = 'Close';
|
---|
142 | SZoomOut = 'Zoom out';
|
---|
143 | SZoomIn = 'Zoom in';
|
---|
144 | SNextPage = 'Next page';
|
---|
145 | SPreviousPage = 'Previous page';
|
---|
146 | SLastPage = 'Last page';
|
---|
147 | SFirstPage = 'First page';
|
---|
148 |
|
---|
149 | implementation
|
---|
150 |
|
---|
151 | procedure Register;
|
---|
152 | begin
|
---|
153 | RegisterComponents('Samples', [TPrintPreview]);
|
---|
154 | end;
|
---|
155 |
|
---|
156 | { TPrintPage }
|
---|
157 |
|
---|
158 | constructor TPrintPage.Create;
|
---|
159 | begin
|
---|
160 | Bitmap := TBitmap.Create;
|
---|
161 | end;
|
---|
162 |
|
---|
163 | destructor TPrintPage.Destroy;
|
---|
164 | begin
|
---|
165 | Bitmap.Free;
|
---|
166 | inherited Destroy;
|
---|
167 | end;
|
---|
168 |
|
---|
169 | { TPrintPreview }
|
---|
170 |
|
---|
171 | function TPrintPreview.GetHeight: Integer;
|
---|
172 | begin
|
---|
173 | if Printer.Printing then Result := Printer.PageHeight
|
---|
174 | else Result := Round(Printer.PageHeight / SizeDivider * Zoom);
|
---|
175 | end;
|
---|
176 |
|
---|
177 | function TPrintPreview.GetPageCount: Integer;
|
---|
178 | begin
|
---|
179 | Result := FPageCount;
|
---|
180 | end;
|
---|
181 |
|
---|
182 | function TPrintPreview.GetPageNumber: Integer;
|
---|
183 | begin
|
---|
184 | if Printer.Printing then Result := Printer.PageNumber
|
---|
185 | else Result := FPageNumber + 1;
|
---|
186 | end;
|
---|
187 |
|
---|
188 | function TPrintPreview.GetWidth: Integer;
|
---|
189 | begin
|
---|
190 | if Printer.Printing then Result := Printer.PageWidth
|
---|
191 | else Result := Round(Printer.PageWidth / SizeDivider * Zoom);
|
---|
192 | end;
|
---|
193 |
|
---|
194 | function TPrintPreview.GetXDPI: Integer;
|
---|
195 | begin
|
---|
196 | if Printer.Printing then Result := Printer.XDPI
|
---|
197 | else Result := Round(ScreenDPI * Zoom);
|
---|
198 | end;
|
---|
199 |
|
---|
200 | function TPrintPreview.GetYDPI: Integer;
|
---|
201 | begin
|
---|
202 | if Printer.Printing then Result := Printer.YDPI
|
---|
203 | else Result := Round(ScreenDPI * Zoom);
|
---|
204 | end;
|
---|
205 |
|
---|
206 | function TPrintPreview.GetZoom: Double;
|
---|
207 | begin
|
---|
208 | if Printer.Printing then Result := 1
|
---|
209 | else Result := FZoom;
|
---|
210 | end;
|
---|
211 |
|
---|
212 | procedure TPrintPreview.SetZoom(const AValue: Double);
|
---|
213 | begin
|
---|
214 | if FZoom = AValue then Exit;
|
---|
215 | FZoom := AValue;
|
---|
216 | Preview;
|
---|
217 | end;
|
---|
218 |
|
---|
219 | procedure TPrintPreview.UpdateMargins;
|
---|
220 | begin
|
---|
221 | Margins := Rect(MMToPixels(MarginsMM.Left), MMToPixels(MarginsMM.Top),
|
---|
222 | MMToPixels(MarginsMM.Right), MMToPixels(MarginsMM.Bottom));
|
---|
223 | end;
|
---|
224 |
|
---|
225 | function TPrintPreview.MMToPixels(AValue: Double; VertRes: Boolean = True): Integer;
|
---|
226 | begin
|
---|
227 | if VertRes then
|
---|
228 | Result := Round(AValue * YDPI / 25.4)
|
---|
229 | else
|
---|
230 | Result := Round(AValue * XDPI / 25.4);
|
---|
231 | end;
|
---|
232 |
|
---|
233 | function TPrintPreview.PixelsToMM(AValue: Integer; VertRes: Boolean): Double;
|
---|
234 | begin
|
---|
235 | if VertRes then
|
---|
236 | Result := AValue / YDPI * 25.4
|
---|
237 | else
|
---|
238 | Result := AValue / XDPI * 25.4;
|
---|
239 | end;
|
---|
240 |
|
---|
241 | procedure TPrintPreview.CreateNewPage;
|
---|
242 | var
|
---|
243 | NewPage: TPrintPage;
|
---|
244 | begin
|
---|
245 | if Printer.Printing then begin
|
---|
246 | Printer.NewPage;
|
---|
247 | end else begin
|
---|
248 | NewPage := TPrintPage.Create;
|
---|
249 | Canvas := NewPage.Bitmap.Canvas;
|
---|
250 | if Pages.Count > 0 then
|
---|
251 | NewPage.Bitmap.Canvas.Font.Assign(TPrintPage(Pages.Last).Bitmap.Canvas.Font);
|
---|
252 | Pages.Add(NewPage);
|
---|
253 | NewPage.Bitmap.SetSize(PageWidth, PageHeight);
|
---|
254 | with NewPage.Bitmap.Canvas do begin
|
---|
255 | Brush.Color := clWhite;
|
---|
256 | Brush.Style := bsSolid;
|
---|
257 | Clear; //Brush.Color := clWhite;
|
---|
258 | Brush.Color := clWhite;
|
---|
259 | Brush.Style := bsSolid;
|
---|
260 | Clear; //Brush.Color := clWhite;
|
---|
261 | //Brush.Style := bsSolid;
|
---|
262 | //FillRect(Rect(0, 0, Width, Height));
|
---|
263 | //Brush.Color := clRed;
|
---|
264 | //Brush.Style := bsSolid;
|
---|
265 | //FillRect(Rect(0, 0, 100, 100));
|
---|
266 | Inc(FPageNumber);
|
---|
267 | end;
|
---|
268 | end;
|
---|
269 | if Assigned(FOnNewPage) then FOnNewPage(Self);
|
---|
270 | end;
|
---|
271 |
|
---|
272 | constructor TPrintPreview.Create(AOwner: TComponent);
|
---|
273 | begin
|
---|
274 | inherited;
|
---|
275 | Zoom := 1;
|
---|
276 | Pages := TObjectList.Create;
|
---|
277 | MarginsMM := Rect(10, 10, 10, 10);
|
---|
278 | end;
|
---|
279 |
|
---|
280 | destructor TPrintPreview.Destroy;
|
---|
281 | begin
|
---|
282 | Pages.Free;
|
---|
283 | inherited Destroy;
|
---|
284 | end;
|
---|
285 |
|
---|
286 | procedure TPrintPreview.Preview;
|
---|
287 | begin
|
---|
288 | if Assigned(FOnPrint) then begin
|
---|
289 | Pages.Clear;
|
---|
290 | FPageNumber := -1;
|
---|
291 | UpdateMargins;
|
---|
292 | CreateNewPage;
|
---|
293 | FOnPrint(Self);
|
---|
294 | end;
|
---|
295 | end;
|
---|
296 |
|
---|
297 | procedure TPrintPreview.Execute;
|
---|
298 | var
|
---|
299 | Form: TPrintPreviewForm;
|
---|
300 | begin
|
---|
301 | try
|
---|
302 | Form := TPrintPreviewForm.Create(nil);
|
---|
303 | Form.PrintPreview := Self;
|
---|
304 | Preview;
|
---|
305 | FPageCount := Pages.Count;
|
---|
306 | Preview; // Call again for page count update
|
---|
307 | Form.ShowModal;
|
---|
308 | finally
|
---|
309 | Form.Free;
|
---|
310 | end;
|
---|
311 | end;
|
---|
312 |
|
---|
313 | procedure TPrintPreview.Print;
|
---|
314 | begin
|
---|
315 | if Assigned(FOnPrint) then begin
|
---|
316 | Canvas := Printer.Canvas;
|
---|
317 | try
|
---|
318 | FPageNumber := 0;
|
---|
319 | Canvas := Printer.Canvas;
|
---|
320 | Printer.Title := UTF8Decode(PageTitle);
|
---|
321 | Printer.BeginDoc;
|
---|
322 | UpdateMargins;
|
---|
323 | FOnPrint(Self);
|
---|
324 | finally
|
---|
325 | Printer.EndDoc;
|
---|
326 | end;
|
---|
327 | end;
|
---|
328 | end;
|
---|
329 |
|
---|
330 |
|
---|
331 | { TPrintPreviewForm }
|
---|
332 |
|
---|
333 | procedure TPrintPreviewForm.APrintExecute(Sender: TObject);
|
---|
334 | begin
|
---|
335 | (* with Printer.Canvas.Font do begin
|
---|
336 | Size := 10;
|
---|
337 | ShowMessage(IntToStr(Height) + ' ' +
|
---|
338 | IntToStr(PixelsPerInch));
|
---|
339 | end;
|
---|
340 | with TPrintPage(PrintPreview.Pages.Last).Bitmap.Canvas.Font do begin
|
---|
341 | Size := 10;
|
---|
342 | ShowMessage(IntToStr(Height) + ' ' + IntToStr(PixelsPerInch));
|
---|
343 | end; *)
|
---|
344 |
|
---|
345 | PrintDialog1.MinPage := 1;
|
---|
346 | PrintDialog1.MaxPage := PrintPreview.PageCount;
|
---|
347 | PrintDialog1.FromPage := 1;
|
---|
348 | PrintDialog1.ToPage := PrintPreview.PageCount;
|
---|
349 | if PrintDialog1.Execute then begin
|
---|
350 | if Assigned(FPrintPreview) then PrintPreview.Print;
|
---|
351 | end;
|
---|
352 | end;
|
---|
353 |
|
---|
354 | procedure TPrintPreviewForm.AZoomInExecute(Sender: TObject);
|
---|
355 | begin
|
---|
356 | PrintPreview.Zoom := PrintPreview.Zoom * 1.25;
|
---|
357 | Redraw;
|
---|
358 | end;
|
---|
359 |
|
---|
360 | procedure TPrintPreviewForm.AZoomOutExecute(Sender: TObject);
|
---|
361 | begin
|
---|
362 | PrintPreview.Zoom := PrintPreview.Zoom / 1.25;
|
---|
363 | EditPageNumberChange(Self);
|
---|
364 | Redraw;
|
---|
365 | end;
|
---|
366 |
|
---|
367 | procedure TPrintPreviewForm.EditPageNumberChange(Sender: TObject);
|
---|
368 | var
|
---|
369 | Value: Integer;
|
---|
370 | begin
|
---|
371 | if TryStrToInt(EditPageNumber.Text, Value) then begin
|
---|
372 | PageNumber := Value;
|
---|
373 | if PageNumber < 0 then PageNumber := 0;
|
---|
374 | if PageNumber >= PrintPreview.PageCount then
|
---|
375 | PageNumber := PrintPreview.PageCount - 1;
|
---|
376 | end;
|
---|
377 | ReloadPageNumber;
|
---|
378 | end;
|
---|
379 |
|
---|
380 | procedure TPrintPreviewForm.FormCreate(Sender: TObject);
|
---|
381 | begin
|
---|
382 | DoubleBuffered := True;
|
---|
383 | end;
|
---|
384 |
|
---|
385 | procedure TPrintPreviewForm.FormDestroy(Sender: TObject);
|
---|
386 | begin
|
---|
387 | end;
|
---|
388 |
|
---|
389 | procedure TPrintPreviewForm.FormResize(Sender: TObject);
|
---|
390 | begin
|
---|
391 | Redraw;
|
---|
392 | end;
|
---|
393 |
|
---|
394 | procedure TPrintPreviewForm.FormShow(Sender: TObject);
|
---|
395 | begin
|
---|
396 | Caption := SPrintPreview;
|
---|
397 | AClose.Caption := SClose;
|
---|
398 | AClose.Hint := SClose;
|
---|
399 | AFirstPage.Caption := SFirstPage;
|
---|
400 | AFirstPage.Hint := SFirstPage;
|
---|
401 | ALastPage.Caption := SLastPage;
|
---|
402 | ALastPage.Hint := SLastPage;
|
---|
403 | ANextPage.Caption := SNextPage;
|
---|
404 | ANextPage.Hint := SNextPage;
|
---|
405 | APreviousPage.Caption := SPreviousPage;
|
---|
406 | APreviousPage.Hint := SPreviousPage;
|
---|
407 | APageSetup.Caption := SPageSetup;
|
---|
408 | APageSetup.Hint := SPageSetup;
|
---|
409 | APrinterSetup.Caption := SPrinterSetup;
|
---|
410 | APrinterSetup.Hint := SPrinterSetup;
|
---|
411 | APrint.Caption := SPrint;
|
---|
412 | APrint.Hint := SPrint;
|
---|
413 | AZoomIn.Caption := SZoomIn;
|
---|
414 | AZoomIn.Hint := SZoomIn;
|
---|
415 | AZoomOut.Caption := SZoomOut;
|
---|
416 | AZoomOut.Hint := SZoomOut;
|
---|
417 |
|
---|
418 | PrintDialog1.MaxPage := PrintPreview.Pages.Count;
|
---|
419 | ReloadPageNumber;
|
---|
420 | Redraw;
|
---|
421 | end;
|
---|
422 |
|
---|
423 | procedure TPrintPreviewForm.ScrollBarHorizChange(Sender: TObject);
|
---|
424 | begin
|
---|
425 | Redraw;
|
---|
426 | end;
|
---|
427 |
|
---|
428 | procedure TPrintPreviewForm.ScrollBarVertChange(Sender: TObject);
|
---|
429 | begin
|
---|
430 | Redraw;
|
---|
431 | end;
|
---|
432 |
|
---|
433 | procedure TPrintPreviewForm.ReloadPageNumber;
|
---|
434 | begin
|
---|
435 | EditPageNumber.Text := IntToStr(PageNumber);
|
---|
436 | Redraw;
|
---|
437 | ANextPage.Enabled := PageNumber < (PrintPreview.PageCount - 1);
|
---|
438 | APreviousPage.Enabled := PageNumber > 0;
|
---|
439 | end;
|
---|
440 |
|
---|
441 | procedure TPrintPreviewForm.Redraw;
|
---|
442 | var
|
---|
443 | //SourceRect: TRect;
|
---|
444 | DestRect: TRect;
|
---|
445 | Page: TPrintPage;
|
---|
446 | begin
|
---|
447 | Page := TPrintPage(PrintPreview.Pages[PageNumber]);
|
---|
448 | //SourceRect := Rect(0, 0,
|
---|
449 | // Page.Bitmap.Canvas.Width,
|
---|
450 | // Page.Bitmap.Canvas.Height);
|
---|
451 | DestRect.Left := -Round(ScrollBarHoriz.Position / ScrollBarHoriz.Max * Width * PrintPreview.Zoom);
|
---|
452 | DestRect.Top := -Round(ScrollBarVert.Position / ScrollBarVert.Max * Height * PrintPreview.Zoom);
|
---|
453 | DestRect.Right := DestRect.Left + Round(Page.Bitmap.Canvas.Width * PrintPreview.Zoom);
|
---|
454 | DestRect.Bottom := DestRect.Top + Round(Page.Bitmap.Canvas.Height * PrintPreview.Zoom);
|
---|
455 | try
|
---|
456 | Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
|
---|
457 | Image1.Picture.Bitmap.BeginUpdate(True);
|
---|
458 | with Image1.Picture.Bitmap, Canvas do begin
|
---|
459 | Brush.Color := clBlack;
|
---|
460 | Brush.Style := bsSolid;
|
---|
461 | FillRect(Rect(0, 0, Width, Height));
|
---|
462 | Draw(DestRect.Left, DestRect.Top, Page.Bitmap);
|
---|
463 | //CopyRect(DestRect, Page.Bitmap.Canvas, SourceRect);
|
---|
464 | Pen.Style := psSolid;
|
---|
465 | Pen.Color := clBlack;
|
---|
466 | Frame(DestRect);
|
---|
467 | end;
|
---|
468 | finally
|
---|
469 | Image1.Picture.Bitmap.EndUpdate;
|
---|
470 | end;
|
---|
471 | end;
|
---|
472 |
|
---|
473 | procedure TPrintPreviewForm.APageSetupExecute(Sender: TObject);
|
---|
474 | begin
|
---|
475 | with PrintPreview do begin
|
---|
476 | PageSetupDialog1.Margins := Rect(MarginsMM.Left * 100,
|
---|
477 | MarginsMM.Top * 100,
|
---|
478 | MarginsMM.Right * 100,
|
---|
479 | MarginsMM.Bottom * 100);
|
---|
480 | if PageSetupDialog1.Execute then begin
|
---|
481 | MarginsMM := Rect(Round(PageSetupDialog1.Margins.Left / 100),
|
---|
482 | Round(PageSetupDialog1.Margins.Top / 100),
|
---|
483 | Round(PageSetupDialog1.Margins.Right / 100),
|
---|
484 | Round(PageSetupDialog1.Margins.Bottom / 100));
|
---|
485 | UpdateMargins;
|
---|
486 | Redraw;
|
---|
487 | end;
|
---|
488 | end;
|
---|
489 | end;
|
---|
490 |
|
---|
491 | procedure TPrintPreviewForm.APreviousPageExecute(Sender: TObject);
|
---|
492 | begin
|
---|
493 | Dec(PageNumber);
|
---|
494 | if PageNumber < 0 then PageNumber := 0;
|
---|
495 | ReloadPageNumber;
|
---|
496 | end;
|
---|
497 |
|
---|
498 | procedure TPrintPreviewForm.ANextPageExecute(Sender: TObject);
|
---|
499 | begin
|
---|
500 | Inc(PageNumber);
|
---|
501 | if PageNumber >= PrintPreview.PageCount then
|
---|
502 | PageNumber := PrintPreview.PageCount;
|
---|
503 | ReloadPageNumber;
|
---|
504 | end;
|
---|
505 |
|
---|
506 | procedure TPrintPreviewForm.ALastPageExecute(Sender: TObject);
|
---|
507 | begin
|
---|
508 | PageNumber := PrintPreview.PageCount - 1;
|
---|
509 | ReloadPageNumber;
|
---|
510 | end;
|
---|
511 |
|
---|
512 | procedure TPrintPreviewForm.AFirstPageExecute(Sender: TObject);
|
---|
513 | begin
|
---|
514 | PageNumber := 0;
|
---|
515 | ReloadPageNumber;
|
---|
516 | end;
|
---|
517 |
|
---|
518 | procedure TPrintPreviewForm.ACloseExecute(Sender: TObject);
|
---|
519 | begin
|
---|
520 | Close;
|
---|
521 | end;
|
---|
522 |
|
---|
523 | procedure TPrintPreviewForm.APrinterSetupExecute(Sender: TObject);
|
---|
524 | begin
|
---|
525 | PrinterSetupDialog1.Execute;
|
---|
526 | end;
|
---|
527 |
|
---|
528 | initialization
|
---|
529 | {$I UPrintPreview.lrs}
|
---|
530 |
|
---|
531 | end.
|
---|
532 |
|
---|