gpt4 book ai didi

delphi - 调用 ShowModal 并设置 PopupParent 是一个好主意吗?在较新的 Delphi 版本中是否有必要?

转载 作者:行者123 更新时间:2023-12-03 15:09:05 25 4
gpt4 key购买 nike

为了防止新创建的模态窗口隐藏在其模态父窗口下,我习惯在调用 ShowModal 时始终设置 PopupParent (如建议的 hereherehere ) :

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

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

我的问题:

  1. 总是设置 PopupParent 是个好主意吗 - 可能是什么由此产生的问题?是否存在可行的替代方案?
  2. 这在较新版本中仍然有必要吗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;

关于delphi - 调用 ShowModal 并设置 PopupParent 是一个好主意吗?在较新的 Delphi 版本中是否有必要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27864668/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com