英雄无敌5完美版:在消息窗口中显示进度条 - SUNSTONE的Delphi笔记 - CSDN博客
来源:百度文库 编辑:九乡新闻网 时间:2024/04/27 15:32:55
在消息窗口中显示进度条 收藏
动态创建消息窗口,并在窗口中显示一个进度条,在进度条范围内选择按钮unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure DialogTimer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
AMsgDialog: TForm;
AProgressBar: TProgressBar;
ATimer: TTimer;
begin
AMsgDialog := CreateMessageDialog('Quickly! Answer Yes or No!', mtWarning, [mbYes, mbNo]);
AProgressBar := TProgressBar.Create(AMsgDialog);
ATimer := TTimer.Create(AMsgDialog);
with AMsgDialog do
try
Tag := 10; //seconds! Caption := 'You have 10 seconds';
Height := 150; with AProgressBar do begin
Name := 'Progress';
Parent := AMsgDialog;
Max := AMsgDialog.Tag; //seconds
Step := 1;
Top := 95;
Left := 8;
Width := AMsgDialog.ClientWidth - 16;
end; with ATimer do
begin
Interval := 1000;
OnTimer := DialogTimer;
end; case ShowModal of
ID_YES: ShowMessage('Answered "Yes".');
ID_NO: ShowMessage('Answered "No".');
ID_CANCEL: ShowMessage('Time up!')
end; //case
finally
ATimer.OnTimer := nil;
Free;
end;
end;procedure TForm1.DialogTimer(Sender: TObject);
var
aPB: TProgressBar;
begin
if not (Sender is TTimer) then Exit; if ((Sender as TTimer).Owner) is TForm then
with ((Sender as TTimer).Owner) as TForm do
begin
aPB := TProgressBar(FindComponent('Progress')); if aPB.Position >= aPB.Max then
ModalResult := mrNo
else
aPB.StepIt;
end;
end;end. 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/sunstone/archive/2009/10/22/4711466.aspx
动态创建消息窗口,并在窗口中显示一个进度条,在进度条范围内选择按钮unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure DialogTimer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
AMsgDialog: TForm;
AProgressBar: TProgressBar;
ATimer: TTimer;
begin
AMsgDialog := CreateMessageDialog('Quickly! Answer Yes or No!', mtWarning, [mbYes, mbNo]);
AProgressBar := TProgressBar.Create(AMsgDialog);
ATimer := TTimer.Create(AMsgDialog);
with AMsgDialog do
try
Tag := 10; //seconds! Caption := 'You have 10 seconds';
Height := 150; with AProgressBar do begin
Name := 'Progress';
Parent := AMsgDialog;
Max := AMsgDialog.Tag; //seconds
Step := 1;
Top := 95;
Left := 8;
Width := AMsgDialog.ClientWidth - 16;
end; with ATimer do
begin
Interval := 1000;
OnTimer := DialogTimer;
end; case ShowModal of
ID_YES: ShowMessage('Answered "Yes".');
ID_NO: ShowMessage('Answered "No".');
ID_CANCEL: ShowMessage('Time up!')
end; //case
finally
ATimer.OnTimer := nil;
Free;
end;
end;procedure TForm1.DialogTimer(Sender: TObject);
var
aPB: TProgressBar;
begin
if not (Sender is TTimer) then Exit; if ((Sender as TTimer).Owner) is TForm then
with ((Sender as TTimer).Owner) as TForm do
begin
aPB := TProgressBar(FindComponent('Progress')); if aPB.Position >= aPB.Max then
ModalResult := mrNo
else
aPB.StepIt;
end;
end;end. 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/sunstone/archive/2009/10/22/4711466.aspx
在消息窗口中显示进度条 - SUNSTONE的Delphi笔记 - CSDN博客
FieldByName速度优化 - SUNSTONE的Delphi笔记 - CSDN博客
UNIGUI中控件类名的变化 - SUNSTONE的Delphi笔记 - CSDN博客
UNIGUI如何禁止关闭新窗口 - SUNSTONE的Delphi笔记 - CSDN博客
如何让BitBtn按钮显示icon图标 - SUNSTONE的Delphi笔记 - CSD...
UNIGUI中如果获得Session情况 - SUNSTONE的Delphi笔记 - CS...
VIM技巧之分隔窗口 - erricwang的笔记 - CSDN博客
delphi listview自绘图形显示进度条 分颜色显示
控制Delphi的窗口显示位置的方法1
delphi 2010 fastMM 内存泄露使用方法 - SUNSTONE的Delphi...
【在窗口上写字】 - 星光中的灯 - CSDN博客
如何在项目中研发 - cyberhong的专栏 - CSDN博客
福利费报销流程1 - DJ(Delphi/JAVA)_fans的专栏 - CSDN博客
使用 glaux 显示 - bbbbbbj的专栏 - CSDN博客
笔记:中断,下半部 - unbutun的专栏 - CSDN博客
Word2007窗口中显示“文档结构图”
如何给Delphi的CPU调试窗口,增加对应源代码
Delphi中PING的实现
MSP430开发笔记 - 人在旅途 - CSDN博客
易语言拦截窗口消息的示例
如何在DELPHI中使用汇编
用键盘控制光标在输入框中跳转的小巧门 - dhlhh的专栏 - CSDN博客
Keil C51汉字显示的bug问题 - willhu2008的专栏 - CSDN博客
把pscp放到右键中 - zokie的专栏 - CSDN博客