easyprogressdlg.pas.svn-base

来自「支持自定义语法高亮显示的编辑器控件」· SVN-BASE 代码 · 共 116 行

SVN-BASE
116
字号
{***********************************************************}
{                                                           }
{ Print progress dialog                                     }
{                                                           }
{  Copyright (c) 1992-2002 Altium Limited                   }
{  All rights reserved.                                     }
{                                                           }
{  http://www.dream-com.com                                 }
{  contact@dream-com.com                                    }
{                                                           }
{***********************************************************}
unit EasyProgressDlg;

interface
{$I Easy.inc}

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, EasyUtils;

type
  TFrmPrintProgress = class(TForm)
    ProgressBar: TProgressBar;
    lbProgress: TLabel;
    Button1: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    FDialogSettings : TEasyDialogSettings;
  public
    { Public declarations }
  end;

var
  FrmPrintProgress: TFrmPrintProgress;

implementation
uses
  EasyPrint;

{$IFNDEF EASY_CLX}
{$R *.DFM}
{$ELSE}
{$R *.xfm}
{$ENDIF}

const
  sPrintProgress = 'Printing page %d of %d';
{--------------------------------------------}

function DisplayPrinProgress(Sender : TObject; AType : TEasyPrintProgressType; Step, Size : integer) : boolean;
begin
  result := true;
  case AType of
    ppShow :
      begin
        FrmPrintProgress := TFrmPrintProgress.Create(Application);
        FrmPrintProgress.Show;
      end;
    ppHide :
      if FrmPrintProgress <> nil then
      begin
        FrmPrintProgress.Close;
        FrmPrintProgress := nil;
      end;
    ppProgress :
      begin
        result := FrmPrintProgress <> nil;
        if result then
        begin
          with FrmPrintProgress do
          begin
            ProgressBar.Position := MulDiv(Step, 100, Size);
            lbProgress.Caption := Format(sPrintProgress, [Step, Size]);
          end;
          Application.ProcessMessages;
        end;
      end;
    end;    
end;

{--------------------------------------------}

procedure TFrmPrintProgress.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
  FrmPrintProgress := nil;
end;

{--------------------------------------------}

procedure TFrmPrintProgress.Button1Click(Sender: TObject);
begin
  Close;
end;

{--------------------------------------------}

procedure TFrmPrintProgress.FormCreate(Sender: TObject);
begin
  FDialogSettings := TEasyDialogSettings.Create(self);
  FDialogSettings.Key := 'PreviewDlg';
  FDialogSettings.LoadSettings;
end;

{--------------------------------------------}

initialization
  OnDisplayPrinProgress := DisplayPrinProgress;
finalization
  OnDisplayPrinProgress := nil;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?