怎么办?关于消息框。 我用MessageBox等类似手段弹出消息框,但如果用户不相应则无法继续。我希望在指定时间后(比如1分钟)自动关闭该消息框。怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没办法,MessageBox是模态的,关闭前主程序无法响应。你可以自己写一个类似messageBox的Form,里面增加一个定时器,到时间了自动关闭。最好别用模态了。用Show. 对,在show之前可以将主form disable掉 可以用一个普通的Form来实现,上面放一个可以操作的按钮,用户点击可以关闭此窗口;另外设计一个定时器,从此Form开始显示计时一段事件,关闭此窗口。 unit uMessageBoxEx;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TFMessageBoxEx = class(TForm) Label1: TLabel; BtnOK: TButton; Timer1: TTimer; procedure Timer1Timer(Sender: TObject); private FSeconds: Integer; { Private declarations } public { Public declarations } end;procedure MessageBoxEx(ACap, AText: string; Seconds: Integer);implementation{$R *.dfm}procedure MessageBoxEx(ACap, AText: string; Seconds: Integer);begin with TFMessageBoxEx.Create(Application) do try Caption := ACap; Label1.Caption := AText; FSeconds := Seconds; ShowModal; finally Free; end;end;procedure TFMessageBoxEx.Timer1Timer(Sender: TObject);begin Dec(FSeconds); if FSeconds < 0 then ModalResult := mrOK;end;end. 关于窗口的大小问题 如何在一个存储过程中执行跨网段的存储过程 请问关于COM+网络访问题,急 bitbtn调用imagelist中的ICON图标? Rave Reports5.0界面问题,很急! (紧急求救)DBLookupComboBox就不能象TComboBox那样自己定义ItemIndex吗? 请问如何在quickrep报表里,计算打印页的总数,然后填在QRlabel中? 能否在Windows繁体98下安装Windows简体98? 【www.51delphi.com怎么进不去了?????】 茫然 改变鼠标 为什么DBChart无法设置,急!!!
用Show.
可以用一个普通的Form来实现,上面放一个可以操作的按钮,用户点击可以关闭此窗口;另外设计一个定时器,从此Form开始显示计时一段事件,关闭此窗口。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TFMessageBoxEx = class(TForm)
Label1: TLabel;
BtnOK: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
FSeconds: Integer;
{ Private declarations }
public
{ Public declarations }
end;procedure MessageBoxEx(ACap, AText: string; Seconds: Integer);implementation{$R *.dfm}procedure MessageBoxEx(ACap, AText: string; Seconds: Integer);
begin
with TFMessageBoxEx.Create(Application) do try
Caption := ACap;
Label1.Caption := AText;
FSeconds := Seconds;
ShowModal;
finally
Free;
end;
end;procedure TFMessageBoxEx.Timer1Timer(Sender: TObject);
begin
Dec(FSeconds);
if FSeconds < 0 then ModalResult := mrOK;
end;end.