Razzupaltuff
Razzupaltuff

Reputation: 2301

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

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.

Upvotes: 3

Views: 8825

Answers (4)

John Y
John Y

Reputation: 364

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

Upvotes: 3

Chris
Chris

Reputation: 1128

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

Upvotes: 4

HC Alberts
HC Alberts

Reputation: 31

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;

    }

Upvotes: 3

Timothy Pratley
Timothy Pratley

Reputation: 10662

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

Upvotes: 1

Related Questions