Unit1.~pas
上传用户:hy6789
上传日期:2021-02-22
资源大小:164k
文件大小:1k
源码类别:

状态条

开发平台:

Delphi

  1. unit Unit1;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, ComCtrls, StdCtrls, ExtCtrls;
  6. type
  7. TForm1 = class(TForm)
  8. ProgressBar1: TProgressBar;
  9. Button1: TButton;
  10.     Button2: TButton;
  11.     Button3: TButton;
  12. procedure Button1Click(Sender: TObject);
  13. procedure FormCreate(Sender: TObject);
  14.     procedure Button2Click(Sender: TObject);
  15.     procedure Button3Click(Sender: TObject);
  16. private
  17. { Private declarations }
  18. public
  19. { Public declarations }
  20. end;
  21. var
  22. Form1: TForm1;
  23. n:integer;
  24. s:integer;
  25. implementation
  26. {$R *.dfm}
  27. procedure TForm1.Button1Click(Sender: TObject);
  28. var
  29. i:integer;
  30. begin
  31. form1.ProgressBar1.Position:=0;
  32. form1.ProgressBar1.Step:=1;
  33. for i:=1 to 100000 do
  34. form1.ProgressBar1.StepIt;
  35. end;
  36. procedure TForm1.FormCreate(Sender: TObject);
  37. var
  38. count:integer;
  39. begin
  40. n:=110000;
  41. s:=0;
  42. count:=100000;
  43. progressbar1.Min:=1;
  44. progressbar1.Max:=count;
  45. //SetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE,
  46. //GetWindowLong(ProgressBar1.Handle,GWL_EXSTYLE)and(not WS_EX_STATICEDGE));{去掉progressbar的边框}
  47. // 设置progressbar的背景颜色
  48. Progressbar1.Brush.Color := cllime;
  49. // 设置progressbar的进度条颜色
  50. PostMessage(ProgressBar1.Handle, $0409, 0, clred);
  51. end;
  52. procedure TForm1.Button2Click(Sender: TObject);
  53. begin
  54. n:=n - 10000;
  55. ProgressBar1.Position:=n;
  56. end;
  57. procedure TForm1.Button3Click(Sender: TObject);
  58. begin
  59. s:=s + 10000;
  60. ProgressBar1.Position:=s;
  61. end;
  62. end.