当另外一个表单以模态方式显示时,如何使表单不被禁用? [英] How can I make a form that is not disabled when another form is shown modally?

查看:128
本文介绍了当另外一个表单以模态方式显示时,如何使表单不被禁用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实用程序对话框(非模态和保持在上),应该在使用应用程序时随时可访问(想一下可以在使用应用程序时用于记录的对话框)即使显示模态对话框

I have a utility dialog (non-modal and stay-on-top) that should be accessible at all times when using the application (think of a dialog that can be used to take notes while working with the application) even if a modal dialog is displayed.

其余的应用程序无法更改。

The rest of the application cannot be changed.

可以吗?如何处理?

推荐答案

当调用 ShowModal 所有现有的顶级窗口都被禁用。这就是模式是如何工作的。如果你有一个窗口,交互是合理的,你只需要重新启动它。

When ShowModal is called, all existing top level windows are disabled. That's how modality is meant to work. If you have a window with which interaction is reasonable, you just need to enable it again.

例如,你可以将它添加到你的实用工具窗口中:

For example, you could add this to your utility window:

type
  TMyUtilityForm = class(TForm)
  protected
    procedure WMEnable(var Message: TWMEnable); message WM_ENABLE;
  end;
....
procedure TMyUtilityForm.WMEnable(var Message: TWMEnable);
begin
  if not Message.Enabled then
    EnableWindow(Handle, True);
  inherited;
end;

这将确保您的实用程序窗口永远不会被禁用。

This will make sure that your utility window can never be disabled.

这篇关于当另外一个表单以模态方式显示时,如何使表单不被禁用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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