使 2 个表格能够相互重叠?
我想要一个单独的表单,与我的主表单“一起”显示,这样它就不会与主表单重叠。
这是一个示例:
注意主程序如何重叠日志?我不知道如何在 Delphi 中做到这一点。
谢谢!
I would like to have a seperate form that shows "along" with my main form, so it does not overlap the main form.
Here's an example:
Notice how the main program, overlaps the log? I can't figure out how to do that in Delphi.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题的答案在于非常有用的窗口功能< /a> MSDN 主题。
相关信息是:
应用程序中的主窗体是其他弹出窗口的所有者(使用 Windows 术语而不是 Delphi 术语)。上面的第一个要点意味着拥有的窗口始终出现在主窗体(所有者)上方。
尝试创建一个包含 3 个表单的应用程序并显示所有表单。 .dpr 看起来像这样:
您将看到主窗体始终位于其他两个窗体的下方,但这些其他拥有的窗体可以位于彼此的上方或下方。当您最小化主窗体时,它们都会消失。
如果您想让所有表单成为顶级无主窗口,您可以这样做:
在我的示例中,对于 TPopupForm2 也是如此。这将导致所有 3 个窗口都有任务栏按钮。
另一种方法是恢复到 Vista 之前的方式,并使应用程序的隐藏窗口成为顶级所有者窗口。您可以通过确保 Application.MainFormOnTaskbar 为 False 来完成此操作。跳过所有 CreateParams 代码,您现在将在任务栏上看到一个窗口,并且您的任何窗口都可以位于任何其他窗口之上,因为顶级所有者窗口是隐藏窗口 Application.Handle。当然,缺点是你失去了 Aero Peek。
所以,我猜你需要做的是让主窗体像往常一样出现在任务栏上,但确保其他窗体不属于主窗体(在 Windows 意义上)。但需要拥有它们以避免它们出现在任务栏中。因此,您可以使用 CreateParams 方法使隐藏的应用程序窗口成为所有者,如下所示:
尽管您在注释中另有说明,但当我这样做时,我发现当我最小化主窗体时,弹出窗体确实是隐藏的。当主窗体恢复时,它会再次显示。因此我认为这确实完全解决了你的问题。
The answers to this question lie in the very useful Window Features MSDN topic.
The pertinent information is:
The main form in your app is the owner (in Windows terminology rather than Delphi terminology) of the other popup windows. The first bullet point above implies that the owned windows always appear above the main form (the owner).
Try creating an app with 3 forms and show them all. The .dpr would look like this:
You will see that the main form is always underneath the other two forms, but these other owned forms can be above or below each other. When you minimize the main form they all disappear.
You could if you want make all of your forms top-level unowned windows:
And like wise for TPopupForm2 in my example. This would result in all 3 windows having taskbar buttons.
One other approach is to revert to the pre-Vista way of things and make the Application's hidden window be the top-level owner window. You do this by making sure that Application.MainFormOnTaskbar is False. Skip all the CreateParams code and you'll now have a single window on the taskbar and any of your windows can be above any other because the top-level owner window is the hidden window Application.Handle. Of course the downside is that you lose your Aero Peek.
So, I guess what you need to do is to make the main form appear on the taskbar as usual, but ensure that the other forms are not owned (in the Windows sense) by the main form. But they need to be owned to avoid having them in the taskbar. So you can make the hidden application window be the owner using the CreateParams method, like so:
Although you state otherwise in the comments, when I do this I find that the popup form is indeed hidden when I minimize the main form. And it is shown again when the main form is restored. Thus I think this does solve your problem completely.
我现在还没有打开Delphi,但是可以设置
并显示子窗体
吗?
或者尝试使用 SetWindowPos() 并设置主窗体上的 hWndInsertAfter 属性类似于 HWND_TOPMOST
I haven't got Delphi open now, but would setting
and show the child form with
work?
or else try using SetWindowPos() and setting the hWndInsertAfter property to something like HWND_TOPMOST on the main form