小弟按照书上的抄作,结果发现有点问题,望指教:
在FORM1放两个BUTTON,一个STATUS.BAR。在其上做两个statusPANEL,代码如下;有个button显示图标的可以出来,发现有个button显示进度条的不出来?
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    StatusBar1: TStatusBar;
    procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
      Panel: TStatusPanel; const Rect: TRect);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  progressbar:tprogressbar;
  progressbarrect:trect;
  iconrect:trect;implementation{$R *.dfm}procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
if panel=statusbar.panels[0] then
iconrect:=rect
else
 progressbarrect :=rect;
end;procedure TForm1.Button1Click(Sender: TObject);
var
i,stepcount:integer;
begin
progressbar:=tprogressbar.create(form1);
stepcount:=10000;
with progressbar do
begin
top:=progressbarrect.top;
left:=progressbarrect.left;
width:=progressbarrect.right-progressbarrect.left;
height:=progressbarrect.bottom-progressbarrect.top;
visible:=true;
try
parent:=statusbar1;
min:=0;
max:=stepcount;
step:=1;
for i:=1 to stepcount do
begin
stepit;
end;
finally
free;
end;
end;
end;procedure TForm1.Button2Click(Sender: TObject);
var
aicon:ticon;
begin
aicon:=ticon.create;
try
aicon.handle:=loadicon(hinstance,'mainicon');
if(aicon.handle<>null)then
begin
statusbar1.Canvas .draw(iconrect.left,iconrect.top,aicon);
end;
finally
aicon.Free;
end;end;procedure TForm1.FormCreate(Sender: TObject);
beginend;end.