Dockable window show/hide weird behavior/bug

Dockable window show/hide weird behavior/bug

basautomationservices
Advocate Advocate
230 Views
2 Replies
Message 1 of 3

Dockable window show/hide weird behavior/bug

basautomationservices
Advocate
Advocate

Hi all,

 

I have a (weird) problem with one of my add-ins that uses a dockable window.  It's starting to drive me a little crazy because I have no clue what is going on.. The option to add it disappears (option is gone at +, and at view->user interface). It seems to happen most of the time, but not consistently. Am not sure is it a bug in Inventor or a mistake on my side.

 

The add-in is loaded as it should. As far as I know I am correctly initializing the window. I have no deactivation implemented, cause I could not find anywhere that this is required. Below is my dockable window initialization code.

 

 

 

public partial class Plugin
{
    private DockableWindow? propertyWindow;
    public static IHost? AppHost { get; set; }

    public void InitializePropertyEditor()
    {
        // create window
        var mainWindow = AppHost.Services.GetRequiredService<MainWindow>();
        mainWindow.WindowStyle = WindowStyle.None;
        mainWindow.ResizeMode = ResizeMode.NoResize;
        mainWindow.Visibility = Visibility.Visible;
        
        // add the window to the inventor window
        var helper = new WindowInteropHelper(mainWindow);
        helper.EnsureHandle();
        var hwnd = helper.Handle;
        
        propertyWindow = GetDockableWindow();
        propertyWindow.DisabledDockingStates = DockingStateEnum.kDockBottom | DockingStateEnum.kDockTop;
        propertyWindow.AddChild(hwnd);
        propertyWindow.ShowVisibilityCheckBox = true; 

        // propertyWindow.Visible = false;

        // add the hook to intercept some key events
        HwndSource.FromHwnd(hwnd)?.AddHook(WndProc);
    }
    
    private DockableWindow GetDockableWindow()
    {
        var internalName = "BasAutomation.PropertyEditor";
        var windowName = "Properties";

        DockableWindow propertyWindow;
        try
        {
            propertyWindow = app.UserInterfaceManager.DockableWindows[internalName];
            logger.LogInformation($"Found existing dockable window. InternalName: {internalName}");
        }
        catch
        {
            propertyWindow = app.UserInterfaceManager.DockableWindows.Add(InventorClient.AddInClientIdFormatted, internalName, windowName);
            logger.LogInformation($"Created new dockable window. InternalName: {internalName}");
        }

        return propertyWindow;
    }

    private const uint DLGC_WANTARROWS = 0x0001;
    private const uint DLGC_WANTTAB = 0x0002;
    private const uint DLGC_WANTALLKEYS = 0x0004;
    private const uint DLGC_HASSETSEL = 0x0008;
    private const uint DLGC_WANTCHARS = 0x0080;
    private const uint WM_GETDLGCODE = 0x0087;
    private const uint WM_SIZING = 0x0214;

    private static IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
        if (msg == WM_GETDLGCODE)
        {
            handled = true;
            return new IntPtr(DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_HASSETSEL | DLGC_WANTTAB | DLGC_WANTALLKEYS);
        }

        return IntPtr.Zero;
    }
}

 

 

 

I found out that inventor stores dockable window state in the registry. When inventor is closed, it writes an entry to the Pane folder. Here position / docking state etc are stored.basautomationservices_0-1737214359705.png



These are my observations, I don't know will this help, but like i said, I'm really lost here:

 

1. If I start fresh, so without the folder with the GUID as name, and without the pane folder entry, and visible = true, the dockable window shows, but is floating. (screenshot attached)

Then I can dock it. When I close it the option to add it back is gone.

basautomationservices_1-1737215587008.png

basautomationservices_2-1737215696275.png

 

When I restart inventor, the window shows docked at the last docked location (before closing)..

 

basautomationservices_3-1737215806508.png

 

2. When the window is active, I don't see it in the User interface dropdown.

basautomationservices_4-1737215878200.png
3. When visible is set to false, I don't see the option to add the window at all. However if I set the visibility to true with VBA, it does show. 

 

4. If I set a docking state and visible = true, it does load the panel everytime. Only again, when I close it, I cannot re-add. Anyway, I want to have the initial state as invisible and not docked, so the user can pick.

5. To make it even stranger, there are random moments that suddenly everything works fine...

basautomationservices_5-1737216113315.png

 

TLDR:

I'm facing an issue with a dockable window in my Autodesk Inventor add-in.

The option to re-add the dockable window disappears inconsistently from both the "+" button and View > User Interface. The dockable window is created successfully. With VBA I can set the window visibility to true and it shows up. 


Does anyone have any idea?

 

 

 

Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro


0 Likes
Accepted solutions (1)
231 Views
2 Replies
Replies (2)
Message 2 of 3

basautomationservices
Advocate
Advocate

Anyone? @MjDeck 

 

The same just happened for my iLogic tab. Maybe something else is going on...

basautomationservices_0-1737475189340.png

 

Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro


0 Likes
Message 3 of 3

basautomationservices
Advocate
Advocate
Accepted solution

Seems fixed in the latest version of inventor 2025 (2025.2.1) 

Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro