whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

76 Visitors Online


 
...show a indeterminate ProgressBar in Win XP?
Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
[ Print tip ]  

Tip Rating (17):  
     


{
  Use this ProgressBar when you do not know the amount of progress toward
  completion but wish to indicate that progress is being made.

  This ProgressBar works only on Windows XP and the ComCtl32.dll version
  6.00 or later is needed. To use the new ComCtrl you have to provide the manifest.
  In Delphi 7 just drop TXPManifest on the form. For prior versions of Delphi
  you have to include the XP manifest resource.
}


unit MarqueeProgressBar;

interface

uses
  
SysUtils, Windows, Classes, Controls, ComCtrls, Messages;

type
  
TMarqueeProgressBar = class(TProgressBar)
  private
    
FActive: Boolean;
    FAnimationSpeed: Integer;
    procedure SetActive(const Value: Boolean);
    procedure SetAnimationSpeed(const Value: Integer);
    procedure UpdateProgressBar;
  protected
    procedure 
CreateParams(var Params: TCreateParams); override;
  public
    constructor 
Create(AOwner: TComponent); override;
  published
    property 
Active: Boolean read FActive write SetActive;
    property AnimationSpeed: Integer read FAnimationSpeed write SetAnimationSpeed;
  end;

const
  
PBS_MARQUEE  = $08;
  PBM_SETMARQUEE = WM_USER + 10;

procedure Register;

implementation

procedure Register
;
begin
  
RegisterComponents('SwissDelphiCenter', [TMarqueeProgressBar]);
end;

constructor TMarqueeProgressBar.Create(AOwner: TComponent);
begin
  inherited
;
  FAnimationSpeed := 60;
end;

procedure TMarqueeProgressBar.CreateParams(var Params: TCreateParams);
begin
  inherited
;
  Params.Style := Params.Style or PBS_MARQUEE;
end;

procedure TMarqueeProgressBar.SetActive(const Value: Boolean);
begin
  
FActive := Value;
  UpdateProgressBar;
end;

procedure TMarqueeProgressBar.SetAnimationSpeed(const Value: Integer);
begin
  
FAnimationSpeed := Value;
  UpdateProgressBar;
end;

procedure TMarqueeProgressBar.UpdateProgressBar;
begin
  if 
FActive then
    
SendMessage(Self.Handle, PBM_SETMARQUEE, 1, FAnimationSpeed)
  else
    
SendMessage(Self.Handle, PBM_SETMARQUEE, 0, 0);
end;

end.

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners