不说啥,看效果:
调用代码:
1 2 3 4 5 6 7 8 9 10 11 |
ShowProgress('正在准备提交数据……',0); Sleep(1000); ShowProgress('正在提交第一阶段数据……',20); Sleep(1000); ShowProgress('正在提交第二阶段数据……',50); Sleep(1000); ShowProgress('正在确认提交结果……',75); Sleep(1000); ShowProgress('结果已确认,提交成功。',100); Sleep(1000); HideProgress; |
源码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
unit progress; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls; type TfrmProgress = class(TForm) Panel1: TPanel; lblHint: TLabel; Panel2: TPanel; pbProgress: TProgressBar; sbCancel: TSpeedButton; tmDelayShow: TTimer; procedure tmDelayShowTimer(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmProgress: TfrmProgress; procedure ShowProgress(AHint:String;AProgress:Integer); procedure HideProgress; implementation {$R *.fmx} procedure ShowProgress(AHint:String;AProgress:Integer); begin if not Assigned(frmProgress) then frmProgress:=TfrmProgress.Create(Application); frmProgress.lblHint.Text:=AHint; frmProgress.pbProgress.Value:=AProgress; if not frmProgress.Visible then frmProgress.tmDelayShow.Enabled:=True; frmProgress.Invalidate; Application.ProcessMessages; end; procedure HideProgress; begin if Assigned(frmProgress) then frmProgress.Hide; end; procedure TfrmProgress.tmDelayShowTimer(Sender: TObject); begin tmDelayShow.Enabled:=False; frmProgress.Show; end; end. |
窗体定义:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
object frmProgress: TfrmProgress Left = 0 Top = 0 BorderStyle = None ClientHeight = 480 ClientWidth = 351 Fill.Color = x80000000 Fill.Kind = Solid Position = ScreenCenter Transparency = True Visible = True FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] DesignerMasterStyle = 3 object Panel1: TPanel Align = Center Size.Width = 297.000000000000000000 Size.Height = 141.000000000000000000 Size.PlatformDefault = False TabOrder = 0 object lblHint: TLabel Align = Client Margins.Left = 5.000000000000000000 Margins.Top = 5.000000000000000000 Margins.Right = 5.000000000000000000 Margins.Bottom = 5.000000000000000000 Size.Width = 287.000000000000000000 Size.Height = 46.000000000000000000 Size.PlatformDefault = False TextSettings.VertAlign = Trailing Text = #27491#22312#25191#34892#25805#20316#65292#35831#31245#20505#8230#8230 end object Panel2: TPanel Align = Bottom Padding.Top = 5.000000000000000000 Position.Y = 56.000000000000000000 Size.Width = 297.000000000000000000 Size.Height = 85.000000000000000000 Size.PlatformDefault = False TabOrder = 1 object pbProgress: TProgressBar Align = Top Orientation = Horizontal Margins.Left = 5.000000000000000000 Margins.Right = 5.000000000000000000 Position.X = 5.000000000000000000 Position.Y = 5.000000000000000000 Size.Width = 287.000000000000000000 Size.Height = 10.000000000000000000 Size.PlatformDefault = False end object sbCancel: TSpeedButton Align = Center ModalResult = 2 Size.Width = 48.000000000000000000 Size.Height = 48.000000000000000000 Size.PlatformDefault = False StyleLookup = 'stoptoolbutton' Text = #21462#28040 end end end object tmDelayShow: TTimer Enabled = False Interval = 500 OnTimer = tmDelayShowTimer Left = 184 Top = 88 end end |
0 条评论
沙发空缺中,还不快抢~