📄 newprogressbar.pas
字号:
unit NewProgressBar;
{
Inno Setup
Copyright (C) 1997-2004 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
TNewProgressBar component - a smooth TProgressBar for Delphi 2 and a 32 bit
TProgressBar for Delphi 2 and all platforms
$jrsoftware: issrc/Components/NewProgressBar.pas,v 1.4 2004/06/26 04:52:06 jr Exp $
}
interface
uses
Classes, Controls, ComCtrls;
type
TNewProgressBar = class(TWinControl)
private
FMin: LongInt;
FMax: LongInt;
FPosition: LongInt;
procedure SetMin(Value: LongInt);
procedure SetMax(Value: LongInt);
procedure SetPosition(Value: LongInt);
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
public
constructor Create(AOwner: TComponent); override;
published
property Min: LongInt read FMin write SetMin;
property Max: LongInt read FMax write SetMax;
property Position: LongInt read FPosition write SetPosition default 0;
end;
procedure Register;
implementation
uses
Windows, CommCtrl;
procedure Register;
begin
RegisterComponents('JR', [TNewProgressBar]);
end;
constructor TNewProgressBar.Create(AOwner: TComponent);
begin
inherited;
Width := 150;
Height := GetSystemMetrics(SM_CYVSCROLL);
FMin := 0;
FMax := 100;
end;
procedure TNewProgressBar.CreateParams(var Params: TCreateParams);
const
PBS_SMOOTH = 1;
begin
InitCommonControls;
inherited;
CreateSubClass(Params, PROGRESS_CLASS);
Params.Style := Params.Style or PBS_SMOOTH;
end;
procedure TNewProgressBar.CreateWnd;
begin
inherited CreateWnd;
SendMessage(Handle, PBM_SETRANGE, 0, MAKELPARAM(0, 65535));
SetPosition(FPosition);
end;
procedure TNewProgressBar.SetMin(Value: LongInt);
begin
FMin := Value;
SetPosition(FPosition);
end;
procedure TNewProgressBar.SetMax(Value: LongInt);
begin
FMax := Value;
SetPosition(FPosition);
end;
procedure TNewProgressBar.SetPosition(Value: LongInt);
begin
if Value < FMin then
Value := FMin
else if Value > FMax then
Value := FMax;
FPosition := Value;
if HandleAllocated then
SendMessage(Handle, PBM_SETPOS, MulDiv(Value - FMin, 65535, FMax - FMin), 0);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -