Einzelnen Beitrag anzeigen

Benutzerbild von CoRe.eXtreem
CoRe.eXtreem

Registriert seit: 30. Nov 2003
61 Beiträge
 
Delphi 2005 Personal
 
#5

Re: ProgressBar Status hin/her bewegen ???

  Alt 7. Aug 2005, 12:15
Achja hier ist der Code, habe ihn zufällig beim stöbern gefunden.

http://www.swissdelphicenter.ch/de/showcode.php?id=1680

Delphi-Quellcode:
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.
Viele Grüße,

CoRe.eXtreem
  Mit Zitat antworten Zitat