加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

调用ShowModal时设置PopupParent是一个好主意,是否有必要在较新

发布时间:2020-12-15 09:23:03 所属栏目:大数据 来源:网络整理
导读:为了防止新创建的模态窗口隐藏在其模态父窗口下,我习惯于在调用ShowModal时设置PopupParent(如建议 here,here和 here): function TMyForm.ShowModal(ParentForm: TCustomForm): Integer;begin PopupParent := ParentForm; Result := inherited ShowModal;en
为了防止新创建的模态窗口隐藏在其模态父窗口下,我习惯于在调用ShowModal时设置PopupParent(如建议 here,here和 here):

function TMyForm.ShowModal(ParentForm: TCustomForm): Integer;
begin
    PopupParent := ParentForm;
    Result := inherited ShowModal;
end;

但是在调试时(在FormCreate中设置丢失表单放置的问题)我意识到设置PopupParent会导致调用ReCreateWindow,从而破坏并重新创建底层的Windows屏幕对象.

我的问题:

>始终设置PopupParent是一个好主意 – 可能是什么
产生的问题?有可行的替代方案吗?
>在新版本中,这仍然是必要的
Delphi(我目前正在使用D2006,但计划更新)?

编辑:

我认为上面所有相关的问题都解决了同样的问题,最好由3rd link描述:

[A form is opened] with ShowModal,this form opens another with ShowModal,so we
have stacked modal forms. There is sometimes a problem that when we call ShowModal
in new form,it hides behind previous forms,instead of showing on top. After pressing
alt+tab,form comes back to the top […]

解决方法

这个问题很古老,但仍然相关.关于此的最佳信息来源是Allen Bauer本人:
http://blog.therealoracleatdelphi.com/2004/02/popupmode-and-popupparent_10.html

(韦巴克:
https://web.archive.org/web/20160324062228/http://blogs.embarcadero.com/abauer/2004/02/10/295)

你找到了这个:
“如果你在ShowModal之前将PopupMode属性显式设置为pmAuto,就像在设计时那样,则不需要重新创建.”

这样你的代码应该是:

function TMyForm.ShowModal(ParentForm: TCustomForm): Integer;
begin
    PopupMode := pmAuto;
    PopupParent := ParentForm;
    Result := inherited ShowModal;
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读