Home Forums WinForms controls Other WinForms controls DockManager ToolWindow initial position.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18540 |

    Hi,

     I’ve attempted to position floating ToolWindows (I’ve disabled docking etc in the dockmanager) before making them visible (or executing Activate()) but they always seem to pick a standard position.

    I have tried using the layout Save/Load but have found a few niggling bugs with it (such as if the tool windows get renamed and no longer exist) so I want to write my own.  I’ve tried using Location (ignored), Size (ignored) and FloatingWindowBounds (this partly works, Size works but the window position does not work).

    Is there any reason why the location is not noticed when I call ResumeLayout() on the dockmanager.  I have tried various workarounds with no joy.  Including:

            public Rectangle Bleb { get; set; }

            protected override void OnVisibleChanged(EventArgs e)

            {

                base.OnVisibleChanged(e);

                if (this.Visible)

                    FloatingWindowBounds = Bleb;

                else

                    Bleb = FloatingWindowBounds;

            } 

    Where I preset Bleb before doing anything else to my desired rectangle. 

    On the initial Visible=true setting, I see FloatingWindowBounds get set to my rectangle only for it to appear somewhere completely different.

    James 

    Imported from legacy forums. Posted by James (had 2359 views)

    User (Old forums)
    Member
    Post count: 23064

    I found one work around that works but not without flickering the tool windows:

      …. DO ALL TOOLWINDOW ADDS HERE AND THEN SET VISIBLE TO FALSE TO EACH (AFTER BEEN ADDED) …

                     dockLayoutManager1.ResumeLayout();

                    /// Work around for the tool window where FloatingWindowBounds

                    /// cannot be loaded before it is visible.

                    /// Unfortunately this causes flickers but can’t do anything about it :'(

                    foreach (ToolWindow toolWindow in dockLayoutManager1.ToolWindows)

                    {

                        GridVirtualUserControlSettings settings = ((GridVirtualUserControlSettings)toolWindow.Tag);

                        if (settings.Active)

                        {

                            toolWindow.ToolWindowVisible = true;

                            toolWindow.FloatingWindowBounds = settings.LocationSize;

                        }

                        else

                        {

                            toolWindow.ToolWindowVisible = true;

                            toolWindow.FloatingWindowBounds = settings.LocationSize;

                            toolWindow.ToolWindowVisible = false;

                        }

                    }

     

    Hopefully it’s clear what I want to achieve here (if I wrap this inside Suspend/ResumeLayout – it fails to produce anything sensible)

     

    Imported from legacy forums. Posted by James (had 455 views)

    User (Old forums)
    Member
    Post count: 23064

    A ToolWindow position cannot be changed within a Suspend/ResumeLayout block or when not visible, so your workaround is the best that can be done.

    Imported from legacy forums. Posted by André (had 3016 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.