如何允许Delphi主窗体背后的辅助表单 [英] How to allow Delphi secondary forms behind the main form
问题描述
如果在Delphi 2010或XE中将Application.MainFormOnTaskbar设置为true,则所有辅助表单总是位于主窗口的前面。无论Popupmode或PopupParent属性设置为什么都无关紧要。不过,我有辅助窗口,我希望能够在主窗体后面显示。
如果我将MainFormOnTaskbar设置为false,它将起作用,但是Windows 7的功能已损坏(Alt标签,Windows栏图标等)。
基本上你不能。整个 MainFormOnTaskBar
的要点是兼容Vista。如果你没有设置它,兼容性就消失了,如果你设置它,z-order就完成了。以下摘录自D2007的自述文件:
该属性控制VCL如何处理Window的TaskBar按钮。此属性可以应用于较旧的应用程序,但它会影响MainForm的Z顺序,所以您应该确保对旧行为没有依赖关系。
但请参阅 QC报告,它描述了完全相同的问题(并且像 AsDesigned 那样关闭)。该报告指出了一种解决方法,涉及覆盖表单的 CreateParams
以将 WndParent
设置为'0'。它还介绍了此解决方法导致的一些问题以及这些问题的可能解决方法。要小心,要找到并解决所有问题并不容易/可能。请参阅Steve Trefethen的文章,感受可能涉及的内容。
If in Delphi 2010 or XE Application.MainFormOnTaskbar is set to true then all secondary forms are always in front of the main window. It does not matter what the Popupmode or PopupParent properties are set to. However I have secondary windows that I want to be able to show behind the the main form.
If I set MainFormOnTaskbar to false it works, but then the Windows 7 features are broken (Alt-tab, Windows bar icon, etc).
How can I keep the Windows 7 features working while still allowing secondary forms to hide behind the main form?
Basically you can't. The whole point of MainFormOnTaskBar
is to have Vista compatibility. If you don't set it, compatibility is gone.., if you set it, z-order is done. The following excerpt is from D2007's readme:
The property controls how Window's TaskBar buttons are handled by VCL. This property can be applied to older applications, but it affects the Z-order of your MainForm, so you should ensure that you have no dependencies on the old behavior.
But see this QC report, which describes the exact same problem (and closed as AsDesigned). The report states a workaround involving overriding CreateParams
of a form to set the WndParent
to '0'. It also describes a few problems which this workaround causes and a possible workaround for those problems too. Beware, it wouldn't be easy/possible to find and workaround all complications. See Steve Trefethen's article to have a feeling of what could be involved.
这篇关于如何允许Delphi主窗体背后的辅助表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!