Weifenluo Dock Panel Suite: Float windows using their design size?

怎甘沉沦 提交于 2019-12-10 19:06:54

问题


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.


回答1:


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



回答2:


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;
}



回答3:


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;

    }



回答4:


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


来源:https://stackoverflow.com/questions/3502759/weifenluo-dock-panel-suite-float-windows-using-their-design-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!