与 FireMonkey 的 MDI 接口
是否可以使用 FireMonkey 创建传统意义上的包含多个文档表单/框架和一个主表单的 MDI 应用程序?
我特别感兴趣,因为表单上不再有 MDI 控件。它是否已被替换为不同的东西?
编辑:添加到问题中,当我创建子表单时,它们都单独显示在任务栏中,甚至是 OpenDialogs..
Is it possible to create an MDI application using FireMonkey in a traditional sense of many documents forms/frames and one master form?
I'm specifically interested since there are no MDI controls on forms anymore.. Has it been replaced with something different?
EDIT: Adding to the question, when I create child forms they all showed separately in taskbar, even the OpenDialogs..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下一种方法:
1) 像平常一样创建单独的表单,除了使用 TLayout,将其称为“LayoutMain”(对齐的 alClient)作为该表单上所有控件的父级。
2)在你的“主窗体”上,当你想要引入一个窗体实例以使其像MDI界面一样运行时,创建一个TLayout(称之为“FormContainer”或其他东西),将其放置为它的子级(与顶部)另一个 TLayout(称之为“FormHeader”),包含表单标题的各个控件、最小化/最大化/关闭按钮以及“框架”标题上您想要的任何其他内容。 这称为 复合。
3) 创建子窗体的一个实例(但不显示),然后将该实例的主 TLayout“LayoutMain”作为主窗体的 TLayout“FormContainer”的父级。
4) 在前面提到的 TLayout(名称为“FormHeader”)上,为其提供
OnMouseDown
和OnMouseMove
事件,以提供在主窗体周围拖动它的能力。当您想要最大化主窗体内的子窗体时,只需将外部 TLayout“FormContainer”align 属性设置为 alClient,记住将其原始顶部、左侧、宽度和高度值存储在窗体实例中,以便您可以按恢复按钮时调用它们。
确实,这是一个相当复杂的解决方案,但据我所知,这是实现您想要使用 FireMonkey 实现的目标的唯一方法,因为它现在存在(大约更新 2)。
我不希望 Embarcadero 提供任何形式的 MDI 模拟作为 FireMonkey“开箱即用”的一部分,因为 MDI 被认为是一种老式方法。
更现代的解决方案是使用 Docking,就像 RAD Studio IDE 本身所做的那样。这提供了两全其美的优点,使用户可以自由选择他们想要链接到主表单的子表单,或自行显示在主表单之外(或停靠安排的任何组合)。
Here's one approach you can use:
1) Create your individual forms as normal, except use a TLayout, call it "LayoutMain", (aligned alClient) as the parent of all controls on that form.
2) On your "master form", when you want to bring a form instance in to behave as it would as an MDI interface, create a TLayout (call it "FormContainer" or something), place as a child of that (aligned to top) another TLayout (call it "FormHeader"), containing the individual controls for the Form Caption, the Minimize/Maximize/Close buttons and anything else you'd like on the "frame" heading. This is called a Composite.
3) Create an instance of your child form (but don't show it), then parent that instance's primary TLayout "LayoutMain" to your main form's TLayout "FormContainer".
4) On the TLayout previously mentioned (with the name "FormHeader"), give it
OnMouseDown
andOnMouseMove
events to provide the ability to drag it around the Master Form.When you want to maximize the child form inside the master form, you'd just set the outer TLayout "FormContainer" align property to alClient, remembering to store its original Top, Left, Width and Height values within the the form's instance so you can recall them when pressing the Restore button.
True, this is a fairly involved solution, but to the very best of my knowledge this is the only way you're going to achieve what you're trying to do with FireMonkey as it exists today (circa Update 2).
I wouldn't expect Embarcadero to provide any form of MDI emulation as part of FireMonkey "out of the box", as MDI is considered an old-fashioned approach.
The more modern solution would be to use Docking, as the RAD Studio IDE itself does. This provides the very best of both worlds, giving the user the freedom to choose what child forms they want to link into the master form, or display outside of that on their own (or any combination of docked arrangements).