unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, xpman;
type
TForm1 =
class(TForm)
ProgressBar1: TProgressBar;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
OldProgressWndProc: TWndMethod;
procedure ProgressWndProc(
var Msg: TMessage);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.ProgressWndProc(
var Msg: TMessage);
var
dc: HDC;
rect: TRect;
begin
OldProgressWndProc (Msg);
if Msg.Msg = WM_PAINT
then
// Wenn die Progressbar neugezeichnet wurde,
// und somit die Zahl weg ist: Prozentzahl neu draufpinseln
begin
dc := GetWindowDC(Progressbar1.Handle);
Windows.GetClientRect(Progressbar1.Handle, rect);
SetBkMode(
dc, TRANSPARENT);
DrawText(
dc, PChar(Text), length(Text), rect, DT_SINGLELINE
or DT_VCENTER
or DT_CENTER);
// vll. noch ReleaseDC(Progressbar1.Handle, dc);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
OldProgressWndProc := ProgressBar1.WindowProc;
ProgressBar1.WindowProc := ProgressWndProc;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
repeat
ProgressBar1.StepIt;
Application.ProcessMessages;
Sleep (50);
until ProgressBar1.Position = 100;
end;
end.