progressdemo.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:3k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit progressdemo;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  5.   Dialogs, dbcgrids, DB, DBTables, ExtCtrls, fcpanel,
  6.   fctrackbar, ComCtrls, fcLabel, StdCtrls, fcDemoRichEdit, Grids, DBGrids,
  7.   fcProgressBar, Gauges;
  8. type
  9.   TProgressForm = class(TForm)
  10.     fcGroupBox1: TfcGroupBox;
  11.     fcDemoRichEdit1: TfcDemoRichEdit;
  12.     fcGroupBox4: TfcGroupBox;
  13.     DBCtrlGrid1: TDBCtrlGrid;
  14.     DataSource1: TDataSource;
  15.     Table1: TTable;
  16.     fcProgressBar1: TfcProgressBar;
  17.     Table1OrderNo: TFloatField;
  18.     Table1CustNo: TFloatField;
  19.     Table1SaleDate: TDateTimeField;
  20.     Table1ShipDate: TDateTimeField;
  21.     Table1EmpNo: TIntegerField;
  22.     Table1ShipToContact: TStringField;
  23.     Table1ShipToAddr1: TStringField;
  24.     Table1ShipToAddr2: TStringField;
  25.     Table1ShipToCity: TStringField;
  26.     Table1ShipToState: TStringField;
  27.     Table1ShipToZip: TStringField;
  28.     Table1ShipToCountry: TStringField;
  29.     Table1ShipToPhone: TStringField;
  30.     Table1ShipVIA: TStringField;
  31.     Table1PO: TStringField;
  32.     Table1Terms: TStringField;
  33.     Table1PaymentMethod: TStringField;
  34.     Table1ItemsTotal: TCurrencyField;
  35.     Table1TaxRate: TFloatField;
  36.     Table1Freight: TCurrencyField;
  37.     Table1AmountPaid: TCurrencyField;
  38.     Table1PercentPaid: TFloatField;
  39.     fcProgressBar2: TfcProgressBar;
  40.     fcProgressBar3: TfcProgressBar;
  41.     Timer1: TTimer;
  42.     procedure fcTrackBar6DrawTickText(Sender: TObject; TickValue: Double;
  43.       var ATickText: String; var ARect: TRect; var DoDefault: Boolean);
  44.     procedure Table1CalcFields(DataSet: TDataSet);
  45.     procedure Timer1Timer(Sender: TObject);
  46.   private
  47.     { Private declarations }
  48.   public
  49.     { Public declarations }
  50.   end;
  51. var
  52.   ProgressForm: TProgressForm;
  53. implementation
  54. {$R *.dfm}
  55. procedure TProgressForm.fcTrackBar6DrawTickText(Sender: TObject;
  56.   TickValue: Double; var ATickText: String; var ARect: TRect;
  57.   var DoDefault: Boolean);
  58. var TickInt: integer;
  59. begin
  60.   TickInt:= Round(TickValue);
  61.   if (abs(TickValue-TickInt)<0.01) then
  62.   begin
  63.     case TickInt of
  64.       0: ATickText:= 'Low';
  65.       1: ATickText:= 'Medium';
  66.       2: ATickText:= 'High';
  67.       3: ATickText:= 'Top Priority';
  68.     end;
  69.   end;
  70. end;
  71. procedure TProgressForm.Table1CalcFields(DataSet: TDataSet);
  72. begin
  73. dataset.fieldbyname('PercentPaid').asinteger:=
  74.    trunc(dataset.fieldbyname('AmountPaid').asfloat/
  75.          dataset.fieldbyname('ItemsTotal').asfloat * 100);
  76. end;
  77. procedure TProgressForm.Timer1Timer(Sender: TObject);
  78. begin
  79.   if fcprogressbar2.progress>=100 then
  80.   begin
  81.      fcprogressbar2.Progress:=0;
  82.      fcprogressbar3.progress:=0;
  83.   end;
  84.   fcprogressbar2.StepIt;
  85.   fcprogressbar3.StepIt;
  86. end;
  87. end.