子窗体始终位于主窗体上方
我正在使用delphi 2007,每次我使用这样的代码创建一个新表单
var
Child : TFrmChild;
begin
Child:=TFrmChild.Create(Self);
Child.Show();
end;
The child form is shown and displayed above all other forms ,这是可以的,但是当单击主表单时子窗体位于主窗体之上。所以我有两个问题,
- 为什么即使在主窗体中单击,子窗体仍保留在主窗体上方?
- 当我点击主窗体时,如何使主窗体保持在所有其他窗体之上?
谢谢
更新
这是子表单的 dfm
object FrmChild: TFrmChild
Left = 549
Top = 308
Caption = 'FrmChild'
ClientHeight = 228
ClientWidth = 213
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
end
I'm using delphi 2007 and each time which I create a new form using a code like this
var
Child : TFrmChild;
begin
Child:=TFrmChild.Create(Self);
Child.Show();
end;
The child form is shown and appears above all others forms , that is ok, but when a click in the main form the child form stays above of the main form. so i have two questions
- why the child form stay above of the main form even if a click in the main form?
- How i can make which the main form stay over all others forms when i click on it?
Thanks
UPDATE
this is the dfm of the child form
object FrmChild: TFrmChild
Left = 549
Top = 308
Caption = 'FrmChild'
ClientHeight = 228
ClientWidth = 213
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您有两个顶层窗口。主窗体是子窗体的所有者。拥有的窗口总是显示在其所有者之上,这只是 Windows 的规则之一。
请注意,所有者我指的是 Windows 概念而不是 Delphi 概念。
Windows 功能主题介绍了规则。关键的说法是:
至于如何让你的应用程序表现不同,我不太确定。例如,如果您将子窗体设置为无主,那么它将有自己的任务栏按钮,并且当主窗体最小化时,它不会最小化。
You have two top level windows. The main form is the owner of the child form. Owned windows always appear above their owners, that's just one of the rules of Windows.
Note that by owner I am referring to the Windows concept rather than the Delphi concept.
The Windows Features topic explains the rules. The key statement is:
As for how to make you app behave differently I'm not so sure. If you make your child form unowned then it will have its own taskbar button and it won't be minimised when the main form is minimised, for example.
此问题已报告给 QualityCentral。 进行设置
简单的解决方法是在项目的 .dpr 文件中 。缺点是失去了一些 Vista 功能。
还有另一种解决方法,但它很笨拙并且存在其他问题(请参阅 QC 的链接)。
This has been reported to QualityCentral. The simple workaround is to set
in your project's .dpr file. The downside is loss of some Vista functionality.
There is another workaround, but it is clumsy and has other problems (see the link to QC).
迟到的回答 - 我刚刚解决了这个问题。我们想要 Aero 风格的 ALT-TAB 和 WIN-TAB 功能,但 MainFormOnTaskBar 导致了第三方组件的一些问题。 (LMD 停靠 - 如果主窗体上有一个停靠站点,子窗体上有一个停靠站点,则拖动子窗体上的停靠项目会将主窗体带到前面)
解决方案是:
TaskBarList.pas
BaseForm.pas:
注意:我没有使用 OleCheck 检查 HRESULTS,因为我希望它在现场静默失败。
Late answer - I have just worked around this issue. We wanted the Aero style ALT-TAB and WIN-TAB funtionality, but MainFormOnTaskBar caused some issues with a third-party component. (LMD Docking - if there was a docksite on the main form and a docksite on a child, dragging a docked item on the child brought the main form to the front)
The solution to this was to:
TaskBarList.pas
BaseForm.pas:
NOTE: I haven't checked the HRESULTS using OleCheck as I would prefer it to fail silently in the field.