unit U_DialogTest;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.ComCtrls,
Vcl.ExtCtrls,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.Styles,
Vcl.Themes;
type
TMyStatusBar = Class(TCustomStatusBar)
protected
procedure DrawPanel(Panel: TStatusPanel; const Rect: TRect); override;
End;
TFormSkin = class(TForm)
TimerStatusProgress: TTimer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure TimerStatusProgressTimer(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FStatusBar: TMyStatusBar;
FProgressBar: TProgressBar;
FdefaultStyleName:String;
public
{ Public declarations }
end;
var
FormSkin: TFormSkin;
implementation
{$R *.dfm}
{ TMyStatusBar }
procedure TMyStatusBar.DrawPanel(Panel: TStatusPanel; const Rect: TRect);
begin
// Do some thing
// Do some thing
// Do some thing
inherited;
end;
procedure TFormSkin.Button1Click(Sender: TObject);
begin
if Assigned(TStyleManager.ActiveStyle) and (TStyleManager.ActiveStyle.Name<>'Windows') then begin
TStyleManager.TrySetStyle('Windows');
end else begin
TStyleManager.TrySetStyle(fdefaultStyleName);
end;
end;
procedure TFormSkin.FormCreate(Sender: TObject);
var
skinfile: string;
var
ProgressBarStyle: LongInt;
begin
// Skinning
if Assigned(TStyleManager.ActiveStyle) then
fdefaultStyleName := TStyleManager.ActiveStyle.Name;
// TStyleManager.TrySetStyle('Windows');
FStatusBar := TMyStatusBar.Create(self);
FStatusBar.Parent := self;
FStatusBar.Panels.Add;
FStatusBar.Panels.Add;
FStatusBar.Panels.Add;
FStatusBar.Panels[0].Width := 160;
FStatusBar.Panels[1].Width := 200;
FStatusBar.Panels[1].Style := psOwnerDraw;
FStatusBar.Panels[1].Bevel := pbNone;
{ create a run progress bar in the status bar }
FProgressBar := TProgressBar.Create(FStatusBar);
FProgressBar.Parent := FStatusBar;
{ set progress bar position and size - put in Panel[2] }
FProgressBar.Left := FStatusBar.Panels.Items[0].Width + 4;
FProgressBar.Top := 2;
FProgressBar.Height := FStatusBar.Height - 2;
FProgressBar.Width := FStatusBar.Panels.Items[1].Width - 6;
{ set range and initial state }
FProgressBar.Min := 0;
FProgressBar.Max := 100;
FProgressBar.Step := 1;
FProgressBar.Position := 0;
end;
procedure TFormSkin.FormDestroy(Sender: TObject);
begin
FProgressBar.free;
end;
procedure TFormSkin.TimerStatusProgressTimer(Sender: TObject);
begin
if FProgressBar.Position = FProgressBar.Max then
FProgressBar.Position := 0;
FProgressBar.Position := FProgressBar.Position + 1;
end;
end.