我的做法:放几个控件在状态栏上。
放两个label,一个image,Visible属性皆为False,label的透明属性为True,颜色为绿;状态栏上有一个面板,Style为psOwnerDraw.详细见以下代码。
由于StatusBar有Canvas和Brush属性,从理论上来说应该可以直接在其onDrawPanel事件中实现,但我的没通过.???unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls,ExtCtrls;type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Button1: TButton;
Label1: TLabel;//实际应用中这些动态生成好一些
Label2: TLabel;//
Timer1: TTimer;//
Button2: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
TempRect:TRect;
public
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);begin
{with StatusBar1 do//这段代码没用,不知何故。
begin
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clRed;
Canvas.FillRect(TempRect);
Canvas.Font.Color := clYellow;
Brush.Style:=bsSolid;
Brush.Color:=clBlue;
ImageList1.Draw(StatusBar1.Canvas,TempRect.Left,TempRect.Top,1);
Canvas.TextOut(TempRect.left + 30, TempRect.top + 2, 'Loading...');
end;} with label1 do
begin
Parent:=StatusBar1;
Font.Color:=clLime;
Caption:='Loading...';
Left:=TempRect.Left+50;
Top:=TempRect.Top+5;
Visible:=True;
end; with label2 do
begin
Parent:=StatusBar1;
Font.Color:=clLime;
Caption:='0';
Left:=TempRect.Left+450;
Top:=TempRect.Top+5;
Visible:=True;
end; with Image1 do
begin
Parent:=StatusBar1;
Image1.Picture.LoadFromFile('icon1.bmp');
Left:=TempRect.Left+20;
Top:=TempRect.Top+5;
Visible:=True;
end; Timer1.Enabled:=True;
end;procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
TempRect:=Rect;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled:=False;
Label1.Caption:='Ready';
Label2.Caption:='0';
Image1.Picture.LoadFromFile('icon2.bmp');
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label2.Caption:=IntToStr(StrToInt(Label2.Caption)+1);
end;end.
放两个label,一个image,Visible属性皆为False,label的透明属性为True,颜色为绿;状态栏上有一个面板,Style为psOwnerDraw.详细见以下代码。
由于StatusBar有Canvas和Brush属性,从理论上来说应该可以直接在其onDrawPanel事件中实现,但我的没通过.???unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls,ExtCtrls;type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Button1: TButton;
Label1: TLabel;//实际应用中这些动态生成好一些
Label2: TLabel;//
Timer1: TTimer;//
Button2: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
TempRect:TRect;
public
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);begin
{with StatusBar1 do//这段代码没用,不知何故。
begin
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clRed;
Canvas.FillRect(TempRect);
Canvas.Font.Color := clYellow;
Brush.Style:=bsSolid;
Brush.Color:=clBlue;
ImageList1.Draw(StatusBar1.Canvas,TempRect.Left,TempRect.Top,1);
Canvas.TextOut(TempRect.left + 30, TempRect.top + 2, 'Loading...');
end;} with label1 do
begin
Parent:=StatusBar1;
Font.Color:=clLime;
Caption:='Loading...';
Left:=TempRect.Left+50;
Top:=TempRect.Top+5;
Visible:=True;
end; with label2 do
begin
Parent:=StatusBar1;
Font.Color:=clLime;
Caption:='0';
Left:=TempRect.Left+450;
Top:=TempRect.Top+5;
Visible:=True;
end; with Image1 do
begin
Parent:=StatusBar1;
Image1.Picture.LoadFromFile('icon1.bmp');
Left:=TempRect.Left+20;
Top:=TempRect.Top+5;
Visible:=True;
end; Timer1.Enabled:=True;
end;procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
TempRect:=Rect;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled:=False;
Label1.Caption:='Ready';
Label2.Caption:='0';
Image1.Picture.LoadFromFile('icon2.bmp');
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label2.Caption:=IntToStr(StrToInt(Label2.Caption)+1);
end;end.
能告诉你们的email吗
能告诉你们的email吗