API dockable window width not working

API dockable window width not working

Jef_E
Collaborator Collaborator
2,046 Views
13 Replies
Message 1 of 14

API dockable window width not working

Jef_E
Collaborator
Collaborator

Hi,

 

I create a AddIn that works with a dockable window. This dockable window has a usercontrol added into it. this user control is much smaller than the dockable window. Now I would like to match the size but the width property does not affect my window?

 

I changed my width from 50 to 40 to 20 and no visible difference. How am I supposed to change the window width?

 

        Private DDCbrowser As DockableWindow
        Private DDC As DocumentDisplayControls ' User Control class

        Private Sub CreateDockableWindow()
            ' Set reference to the user interface manager
            Dim oUserInterfaceMgr As UserInterfaceManager
            oUserInterfaceMgr = m_inventorApplication.UserInterfaceManager

            ' Create a new dockable window
            DDCbrowser = oUserInterfaceMgr.DockableWindows.Add("SampleClientId", "DDCIntName", "Ellimetal DDC")

            DDC = New DocumentDisplayControls
            DDCbrowser.AddChild(DDC.Handle)

            ' Dock the window to the right
            DDCbrowser.DockingState = DockingStateEnum.kDockRight

            ' Show the title bar
            DDCbrowser.ShowTitleBar = True
            DDCbrowser.Width = 20

            ' Set the dockable window visible
            DDCbrowser.Visible = True
        End Sub


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
2,047 Views
13 Replies
Replies (13)
Message 2 of 14

Jef_E
Collaborator
Collaborator

Still looking for the solution..



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 3 of 14

frederic.vandenplas
Collaborator
Collaborator

 

This needs some more investigation, i thought i found a solution, but it still needs some tweaks

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 4 of 14

AlexFielder
Advisor
Advisor

Hi @Jef_E,

 

I have yet to do any work with Dockable windows myself, but the chap who wrote/created the "MyVaultBrowser" addin for Inventor* has provided the source code over on https://github.com:

 

https://github.com/smilinger/MyVaultBrowser

 

Perhaps in there he has achieved the very answer you are looking for?

 

*In case you weren't aware, this addin first gets the Vault Addin instance and then separates the Vault browser window into a separate dockable window.

0 Likes
Message 5 of 14

frederic.vandenplas
Collaborator
Collaborator

As far i have found, is that the model browser is causing the problem, if you close it, the width will change.

But if you switch it back on, the width of the modelbrowser is the new width of the dockable windows.

 

And as far i know, the api of the modelbrowser is not exposed... (just guessing)

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 6 of 14

Jef_E
Collaborator
Collaborator

I think "The Chap" does not set the width of the dockable window. He does set a minimum size..

 

_myVaultBrowser.SetMinimumSize(200, 150)
Spoiler
public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            _inventorApplication = addInSiteObject.Application;

            try
            {
                _vaultAddin = _inventorApplication.ApplicationAddIns.ItemById["{48b682bc-42e6-4953-84c5-3d253b52e77b}"];
            }
            catch
            {
                MessageBox.Show(Resources.VaultAddinNotFound, @"MyVaultBrowser", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                throw;
            }

            _applicationEvents = _inventorApplication.ApplicationEvents;
            _dockableWindowsEvents = _inventorApplication.UserInterfaceManager.DockableWindows.Events;
            _userInterfaceEvents = _inventorApplication.UserInterfaceManager.UserInterfaceEvents;

            _activeProjectType = _inventorApplication.DesignProjectManager.ActiveDesignProject.ProjectType;

            _hwndDic = new Dictionary<Document, IntPtr>();
            Hook.Initialize(this);

            _myVaultBrowser =
                _inventorApplication.UserInterfaceManager.DockableWindows.Add("{ffbbb57a-07f3-4d5c-97b0-e8e302247c7a}",
                    "myvaultbrowser", "MyVaultBrowser");
            _myVaultBrowser.Title = "Vault";
            _myVaultBrowser.ShowTitleBar = true;
            _myVaultBrowser.DisabledDockingStates = DockingStateEnum.kDockBottom | DockingStateEnum.kDockTop;
            _myVaultBrowser.SetMinimumSize(200, 150);

            SetShortCut();

            if (!_myVaultBrowser.IsCustomized)
            {
                _myVaultBrowser.DockingState = DockingStateEnum.kDockRight;
                _myVaultBrowser.Visible = true;
            }

            _applicationEvents.OnActiveProjectChanged += ApplicationEvents_OnActiveProjectChanged;
            _userInterfaceEvents.OnResetShortcuts += UserInterfaceEvents_OnResetShortcuts;

            if (_inventorApplication.Ready)
            {
                if (_activeProjectType == MultiUserModeEnum.kVaultMode)
                    TryLoadVaultAddin();
            }
            else
                _applicationEvents.OnReady += ApplicationEvents_OnReady;

        }

I found this in the API:

 

DockableWindow.Width Property

 

Parent Object: DockableWindow

 

Description

Property that gets and sets the current width of the window. Setting the width may fail in certain situations such as when the window is docked to the top or bottom and spans the entire width of the Inventor frame.

 

Syntax

DockableWindow.Width() As Long

 

Version

Introduced in Inventor version 2011

 

 

But my window is docked to the right..

 

' Dock the window to the right
DDCbrowser.DockingState = DockingStateEnum.kDockRight

It would be nice if Autodesk would respond to this thread.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 7 of 14

NachoShaw
Advisor
Advisor

Hi

 

are you setting the width of the usercontrol to be the same width as the dockable window?

 

 

cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 8 of 14

Jef_E
Collaborator
Collaborator

@nmjshaw150 wrote:

 

are you setting the width of the usercontrol to be the same width as the dockable window?



No, is this a requirement? 😄 I thought the usercontrol is "docked" into the dockablewindow and is resized with it?

 

EDIT: I tried it, but no succes.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 9 of 14

NachoShaw
Advisor
Advisor

Hi

 

Only if you have set it to be fully docked. What method did you use? I do the following:

 

  • Add a generic frame control to the form and make sure it is anchored and positioned just as i like it
  • Create a UserControl with all of my controls
  • Rebuild my application
  • Add the UserControl to the generic frame at runtime and dock it to the frame

 

Reason for this

  • I can keep the exact size & position i want on the form without too much difficulty
  • i can load other UserControls on the fly and not have to worry about size issues

 

Obviously you dont need to do this, its just what i do

 

 

 

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 10 of 14

Jef_E
Collaborator
Collaborator

I don't have aclue how I did it and if it's "fully docked"

 

I created a usercontrol and added it into my dockable window like this.

 

        Private DDCbrowser As DockableWindow
        Private DDC As DocumentDisplayControls

        Private Sub CreateDockableWindow()
            ' Set reference to the user interface manager
            Dim oUserInterfaceMgr As UserInterfaceManager
            oUserInterfaceMgr = m_inventorApplication.UserInterfaceManager

            ' Create a new dockable window
            DDCbrowser = oUserInterfaceMgr.DockableWindows.Add("SampleClientId", "DDCIntName", "Ellimetal DDC")

            DDC = New DocumentDisplayControls
            DDCbrowser.AddChild(DDC.Handle)

            ' Dock the window to the right
            DDCbrowser.DockingState = DockingStateEnum.kDockRight

            ' Show the title bar
            DDCbrowser.ShowTitleBar = True
            DDCbrowser.Width = DDC.Width


            ' Set the dockable window visible
            DDCbrowser.Visible = True
        End Sub


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 11 of 14

Maxim-CADman77
Advisor
Advisor

Have this been solved?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 12 of 14

Anonymous
Not applicable

Hello @Maxim-CADman77

 

I created a dockable window with the code below and works fine.
The code is C#.

 UserInterfaceManager uiApp = invApp.UserInterfaceManager;
            DockableWindow dockableWindow;
            dockableWindow = uiApp.DockableWindows.Add("SampleId", "SampleInternalName", "Sample Dock");
            dockableWindow.AddChild(CreateForm());
            dockableWindow.DockingState = DockingStateEnum.kDockRight;            
            dockableWindow.ShowVisibilityCheckBox = true;
            dockableWindow.ShowTitleBar = true;
            dockableWindow.Width = 350;
            dockableWindow.SetMinimumSize(900, 32);
            dockableWindow.DisableCloseButton = false; 
            dockableWindow.Visible = true;

And form from here:

private object CreateForm()
        {
            Myform myForm= new Myform ();
            myForm.AutoSize = true;
            myForm.Show();            
            return myForm.Handle;
        }

I am use 2019 version.

 

0 Likes
Message 13 of 14

dba78
Advocate
Advocate

Hi, I'm afraid you missed the point.

Changing the Height/Width on runtime is the problem. It seems to work initially (later occasionally), but as far as I could see, the SetMinimiumSize method is only honored once, so you cannot respond on runtime, e.g. different MinSize fo Top/bottom as for the others....

 

Alltogether the DockableWindow-APi seems not to be implemented very well.....

0 Likes
Message 14 of 14

Jef_E
Collaborator
Collaborator

For me the dockable window width is not set correctly, the window width differes from my input.

 

    Private Sub CreateDockableWindow()
        ' Set reference to the user interface manager
        Dim oUserInterfaceManager As UserInterfaceManager =
            XpressTools.StandardAddInServer.m_inventorApplication.UserInterfaceManager

        ' Create a new dockable window
        Browser = oUserInterfaceManager.DockableWindows.Add("XpressTools-DID-ID", "DIDintName", "XpressTools browser")

        ' Dock the window to the right
        Browser.DockingState = DockingStateEnum.kDockRight

        ' Show the title bar
        Browser.ShowTitleBar = True

        ' Set the dockable window visible
        Browser.Visible = True

        ' Disable certain docking positions
        Browser.DisabledDockingStates = DockingStateEnum.kDockBottom And DockingStateEnum.kDockBottom

        ' Set the window width
        Browser.Width = 230

        ' Set the minumum size for the browser.
        Browser.SetMinimumSize(300, 220)

        ' Add control to the dockable window
        Browser.AddChild(Me.Handle)
    End Sub

The minimum size is set indeed, but the dockable window size is more like 350 and is too large for me.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes