如何分离面板并将其显示在单独的窗口中? [英] How to detach a panel and show it in a separate window?

查看:19
本文介绍了如何分离面板并将其显示在单独的窗口中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含面板(其中包含许多其他控件)的表单 A 和一个空的表单 B.
我可以以编程方式将面板从表单 A 上分离并将其移动到表单 B 中(也可能返回表单 A)吗?

Let's say I have form A that contains a panel (with many other controls in it) and a form B that it is empty.
Can I programmatically detach the panel from form A and move it in form B (and maybe back to form A)?

我知道我可以更改面板的所有者,但它可以在不同的表单之间使用吗?

I know that I can change the Owner of the panel but does it work between different forms?

更新:
经过一番谷歌搜索后,我看到有一个 ParentWindow 属性.

Update:
After some Googling I see that there is a ParentWindow property.

推荐答案

通过真正将 TForm 用于您将使用面板的目的,您可以轻松地将某些东西显示为面板,也可以显示为表单.然后在运行时将表单停靠到您为此目的留下空白面板的位置,并在运行时以相同的方式取消停靠.

You can easily have something appear as if it was a panel, and also as a form, by really using a TForm for what you would have used the panel for. Then dock the form at runtime into the place where you have a blank panel left for that purpose, and undock it at runtime, by the same manner.

您无法取消停靠 TPanel 并将其显示为顶级表单窗口,但您可以使用顶级表单窗口并将其停靠在代码中.要获得您想要的外观和功能,您必须使用正确的工具(在本例中为 TForm).

You can't undock a TPanel and have it appear as a top-level form window, but you can take a top level form window and dock it in code. To get the appearance and functionality you want you must use the correct tools (TForm, in this case).

顺便说一句,像 Toolbar 2000 这样的组件库确实允许基于工具栏面板的浮动工具栏窗口,所以如果您真的坚持让所有设计元素保持在一种形式,在设计时,您应该研究它在 Toolbar 2000 中的工作方式.它有很多代码可以在取消停靠/浮动"模式下呈现工具栏,并处理鼠标驱动的工具栏停靠和取消停靠到工具栏停靠栏.

Incidentally, component libraries like Toolbar 2000 do allow floating toolbar windows based on toolbar panels, so if you really insist on having all the designtim elements remain in one form, at desigtime, you should look into how it works in Toolbar 2000. It has a lot of code in there to render the toolbar in "undocked/floating" mode, and to handle the mouse-driven docking and undocking of toolbars into toolbar docks.

这篇关于如何分离面板并将其显示在单独的窗口中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆