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

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

问题描述

假设我有一个表单A,其中包含一个面板(其中包含许多其他控件)和一个B表示它是空的。

我可以以编程方式从面板A中分离面板并将其移动到形式B(也许回到形式A)?



我知道我可以更改面板的所有者,但是它可以在不同的窗体之间工作吗?



更新:

经过一些Google搜索,我看到有一个ParentWindow属性。

解决方案

您可以轻松地将某些东西看起来像是一个面板,也可以作为一个表单,通过真正使用TForm,您将使用面板。然后将运行时的表单停放到您为此目的留下空白面板的位置,并以相同的方式在运行时将其取消停靠。



您不能取消停用TPanel,并将其显示为顶级窗体窗口,但您可以使用顶级窗体窗口并将其停靠在代码中。要获得所需的外观和功能,您必须使用正确的工具(在这种情况下为TForm)。



顺便提一句,组件库(如Toolbar 2000)允许基于工具栏面板的浮动工具栏窗口,所以如果你真的坚持让所有的designtim元素保持在一种形式,在desigtime你应该研究它在工具栏2000中的工作原理。它有很多代码可以在浮点/浮动模式下渲染工具栏,并处理鼠标驱动的对接和工具栏的工具栏到工具栏的停靠点。 p>

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?

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

解决方案

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.

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).

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天全站免登陆