从我的应用程序中,我希望打开一个对话框,在某些情况下应该立即关闭(在短消息之后)。如何在打开后立即关闭模式表单?
我已经试过这样:
procedure TForm2.FormActivate(Sender: TObject);
begin
if SomeCondition then
begin
ShowMessage('You can''t use this dialog right now.');
close;
modalresult := mrCancel;
end;
end;
,但该对话框保持打开状态。我也试着把代码放在OnShow事件中,但结果是一样的。
为什么不能正常工作?
谢谢,这很有效。 – 2010-08-06 09:10:55