Weifenluo Dock Panel Suite:浮动窗口使用其设计尺寸?

发布于 2024-09-14 16:38:54 字数 126 浏览 8 评论 0原文

如何通过 Weifenluo Dock Panel 套件使浮动窗口使用其设计尺寸(而不是 Dock 面板套件的默认尺寸)?

提示:我尝试了 SF.net 上 Dock Panel Suite 论坛的建议,但这似乎不起作用。

How can I make floating windows use their design size (and not the Dock Panel Suite's default size) with the Weifenluo Dock Panel suite?

Hint: I tried a proposition from the Dock Panel Suite forums at SF.net, but that doesn't seem to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

岁月无声 2024-09-21 16:38:54

我自己寻找答案时偶然发现了这个问题,并发现蒂莫西的答案对我不起作用。

问题是他概述的方法默认情况下也会浮动窗口。 (也许这是版本差异)

我已经用另一种方式解决了这个问题。我创建了一个继承自 DockContent 的基类,我的所有文档窗口都将从它继承。然后,我为处理此问题的 Show 方法创建了另一个重载(我使用 DockPanelSuite 源代码来帮助构建此方法)。

public void Show(DockPanel dockPanel, DockState dockState, Rectangle floatWindowBounds)
{
    Show(dockPanel, dockState); //shows the panel like normal

    //now for the part to initialize the float pane and size
    if (DockHandler.FloatPane == null)
    {
        DockHandler.FloatPane = dockPanel.DockPaneFactory.CreateDockPane(this, DockState.Float, false);
        DockHandler.FloatPane.FloatWindow.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
    }
    DockHandler.FloatPane.FloatWindow.Bounds = floatWindowBounds;
}

I stumbled across this question when looking for the answer myself, and found Timothy's answer to not work for me.

The problem was that the method he outlines also floated the window by default. (maybe that's a version difference)

I have solved this another way. I've created a base class that inherits from DockContent that all my document windows would inherit from. I then created another overload for the Show method that handles this (I used the DockPanelSuite source code to help build this method).

public void Show(DockPanel dockPanel, DockState dockState, Rectangle floatWindowBounds)
{
    Show(dockPanel, dockState); //shows the panel like normal

    //now for the part to initialize the float pane and size
    if (DockHandler.FloatPane == null)
    {
        DockHandler.FloatPane = dockPanel.DockPaneFactory.CreateDockPane(this, DockState.Float, false);
        DockHandler.FloatPane.FloatWindow.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
    }
    DockHandler.FloatPane.FloatWindow.Bounds = floatWindowBounds;
}
面如桃花 2024-09-21 16:38:54

当 CForm 派生自 DockContent 时,
我的 MDIContainerWindow 中有一个方法,如下所示

 public void ShowForm(CForm pForm)
    {
        pForm.MdiParent = this;

        Size lS = pForm.Size;
        dockPanel.DefaultFloatWindowSize = lS;

        pForm.Show(dockPanel);
        pForm.VisibleState = DockState.Float;

    }

when CForm is derived from DockContent,
I have a method within my MDIContainerWindow which looks like this

 public void ShowForm(CForm pForm)
    {
        pForm.MdiParent = this;

        Size lS = pForm.Size;
        dockPanel.DefaultFloatWindowSize = lS;

        pForm.Show(dockPanel);
        pForm.VisibleState = DockState.Float;

    }
懷念過去 2024-09-21 16:38:54

这对我有用(在VB中):

Dim MyForm As New MyForm
MyForm.Show(DockPanel, New Rectangle(MyForm.Location, MyForm.Size))
MyForm.DockState = DockState.DockRight

This is working for me (in VB):

Dim MyForm As New MyForm
MyForm.Show(DockPanel, New Rectangle(MyForm.Location, MyForm.Size))
MyForm.DockState = DockState.DockRight
数理化全能战士 2024-09-21 16:38:54

这对我有用:

var topLeft = dockPanel1.Location;
topLeft.X += (dockPanel1.Size.Width / 2 - newForm.Size.Width / 2);
topLeft.Y += (dockPanel1.Size.Height / 2 - newForm.Size.Height / 2);
newForm.Show(dockPanel1, new Rectangle(topLeft, newForm.Size));

This worked for me:

var topLeft = dockPanel1.Location;
topLeft.X += (dockPanel1.Size.Width / 2 - newForm.Size.Width / 2);
topLeft.Y += (dockPanel1.Size.Height / 2 - newForm.Size.Height / 2);
newForm.Show(dockPanel1, new Rectangle(topLeft, newForm.Size));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文