unit MFPreview;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  RVScroll, CRVPP, SRVPreview, ExtCtrls, StdCtrls, Spin, Buttons;

type
  TFPreview = class(TForm)
    Panel1: TPanel;
    SRVPreview1: TSRVPreview;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    PageNo: TSpinEdit;
    Label1: TLabel;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure PageNoChange(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPreview: TFPreview;

implementation

uses Math, MFBuy;

{$R *.DFM}

procedure TFPreview.SpeedButton5Click(Sender: TObject);
begin
  Close;
end;

procedure TFPreview.SpeedButton1Click(Sender: TObject);
begin
  SRVPreview1.Prev;
  PageNo.Value := SRVPreview1.PageNo;
end;

procedure TFPreview.SpeedButton2Click(Sender: TObject);
begin
  SRVPreview1.Next;
  PageNo.Value := SRVPreview1.PageNo;
end;

procedure TFPreview.PageNoChange(Sender: TObject);
begin
  PageNo.MaxValue := frmBuy.srve.PageCount;
  PageNo.Value := Min(Max(PageNo.Value, 1), PageNo.MaxValue);
  SRVPreview1.PageNo := PageNo.Value;
end;

procedure TFPreview.SpeedButton3Click(Sender: TObject);
begin
  with frmBuy do
  if PrintDialog1.Execute then
    SRVPrint1.PrintPages(PrintDialog1.FromPage, PrintDialog1.ToPage,
      'Order', PrintDialog1.Copies, PrintDialog1.Collate);
end;

end.
