使用'form.showmodal'方法无法使可见窗口模态错误 [英] Cannot Make A Visible Window Modal error using 'form.showmodal' method

查看:143
本文介绍了使用'form.showmodal'方法无法使可见窗口模态错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个multiforms应用程序,只需要在启动时创建主窗体,并根据需要动态创建每个新的附加窗体,通过创建该窗体对象,将其用作模态,一旦该窗体的目的完成,它关闭后会从内存中释放出来。只有我的主表单是自动创建,所有其他表单在项目选项中设置为可用。



这是示例代码。



结果表格被声明为TResultForm的全局变量。

I am trying to make a multiforms application by having only the main form created on start up and creating each new additional form dynamically as needed by creating that form object, using it as a modal and once that form's purpose is complete, it is freed from memory after it is closed. Only my main form is 'auto-created', all additional forms are set as 'available' in the the project options.

Here is sample code.

results form is declared as a global variable of TResultForm.

procedure TMainForm.Button1Click(Sender: TObject);
begin
  ResultsForm := TResultForm.Create(self);
  try
    ResultsForm.ShowModal;
  finally
    ResultsForm.Free;
  end;
end;





我称之为此方法的那一刻点击按钮我收到一条错误信息:



'无法制作可见的窗口模态。'



在该表单(ResultsForm)上,我将数据库链接到该表单并显示。代码适用,没问题。自从尝试使用Embarcadero帮助工具的新示例代码时,只加载新表单(ResultsForm)上的控件,该表单上没有明确添加的代码启动。



The moment I call this method by clicking on the button I recieve an error message:

'Cannot make a visible window modal.'

On that form (ResultsForm) I have databases being linked to that form and displayed. Code for that works, no problems. Since trying this new sample code sourced from Embarcadero's help tool, only the controls on the new form (ResultsForm) are loaded, no explicitly added code on that form initiates.

推荐答案

如果用户关闭模态表单,它已经消失。



祝你好运!
In case the user closes the modal form, it is already gone.

Good luck!


我认为消息是相当清楚。模态对话框用作临时窗口,弹出窗口并显示某些信息或询问用户输入。它不应该是一个全局对象,而是仅在需要时创建并在使用后销毁。根据你的描述,似乎你正在尝试使用现有的窗口,并以某种方式使其成为模态。
I think the message is reasonably clear. A modal dialog is used as a temporary Window which pops up and either displays some information or asks for input from the user. It should not be a global object, but created only when needed and destroyed after use. From your description it seems like you are trying to use an existing Window and somehow make it modal.


有人告诉我,只有一个我没做的小钥匙。代码:



注意,ResultForm可以声明为TResultForm的全局变量或局部变量。不确定之后是否会产生差异。

Someone showed me that there was just one small key that I didn't do. The code:

Note that ResultForm may be declared as an global variable of TResultForm or as a local variable. Not yet sure if a difference arrises later though.
procedure TMainForm.Button1Click(Sender: TObject);
begin
  ResultsForm := TResultForm.Create(self);
  try
    ResultsForm.ShowModal;
  finally
    ResultsForm.Free;
  end;
end;


用于动态创建新表单的
是合理的但是应该注意注意动态创建的表单必须设置其可见性设置为FALSE。否则会出现如下错误:



'无法制作可见的窗口模态。'



将出现。



可能看起来很合乎逻辑,希望没有其他人犯同样的愚蠢错误!


for dynamically creating a new form is sound but one should take care to note that the dynamically created form MUST HAVE ITS VISIBILITY SET TO FALSE. Else an error like:

'Cannot make a visible window modal.'

will appear.

Probably seems very logical, hopefully nobody else makes this same stupid mistake!


这篇关于使用'form.showmodal'方法无法使可见窗口模态错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆