Dockable window width not working??

Dockable window width not working??

Jef_E
Collaborator Collaborator
996 Views
4 Replies
Message 1 of 5

Dockable window width not working??

Jef_E
Collaborator
Collaborator

Hi!

I’m trying to create my own AddIn, well I already made it 😄 but I’m having some trouble. I use a dockable window, but the width property is not adjusting well. In visual studio the width is set correct but at runtime my dockable window is a lot wider than I want it to be. How can is solve this problem?

 

I tried setting the width with the code below, but this has no effect..

 

        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
997 Views
4 Replies
Replies (4)
Message 2 of 5

schmidmi
Autodesk
Autodesk

Hello -

 

Thanks for the question!  I've been working on this a bit this afternoon, and I've created an example that seems to give more consistent results (although admittedly, I don't believe it's perfect and is a bit of a work-around).

 

The short answer, is that I believe trying to set the width before setting the window visible is problematic.  When a window is shown, it attempts to restore the "previous" height/width where it can - this could also be happening during a dock operation.  As such, I created a VBA script similar to yours, but instead update the width after setting the window visible.

 

Sub DockableWindowExample1()
    
    Dim oUserInterfaceMgr As UserInterfaceManager
    Set oUserInterfaceMgr = ThisApplication.UserInterfaceManager

    ' Create a new dockable window
    Dim oWindow As DockableWindow
    Set oWindow = oUserInterfaceMgr.DockableWindows.Add("SampleClientId", "testwindowinternalname", "Test Window")
        
    oWindow.DockingState = kDockRight
    oWindow.ShowTitleBar = True
    oWindow.Visible = True
    
    ' May not always be necessary, but seemed to help ensure the window
    ' properly re-painted as expected.
    oWindow.DockingState = oWindow.DockingState
    oWindow.Width = 300
    Call oUserInterfaceMgr.DoEvents
    
End Sub

Please let me know if this does not give you better results.

 

Thanks!


Michael Schmidt, Principal Engineer
0 Likes
Message 3 of 5

Jef_E
Collaborator
Collaborator

This is my code now, the width is set, but the docking state is not working now..

 

        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

            ' Set the dockable window visible
            DDCbrowser.Visible = True

            ' Set the window width
            DDCbrowser.DockingState = DDCbrowser.DockingState
            DDCbrowser.Width = 220
        End Sub


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

Inventor 2014 SP2
0 Likes
Message 4 of 5

schmidmi
Autodesk
Autodesk

What version of Inventor are you using?  I was working with the latest release, so perhaps there is a difference there.  Your signature says Inventor 2014 SP2 - is that the version you are creating this add-in on?


Michael Schmidt, Principal Engineer
0 Likes
Message 5 of 5

Jef_E
Collaborator
Collaborator

Yes, it is.



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

Inventor 2014 SP2
0 Likes