Hi,
I am having an issue with toolbars created through the API not remembering their proper state (location and visibility). I'm currently on SW 2013 SP3 x64, but this was happening previously as well. Here is the situation.
Create a command group by calling the following pertinent functions:
cmdMgr.GetGroupDataFromRegistry
cmdMgr.CreateCommandGroup2
cmdGroup.HasMenu
cmdGroup.HasToolbar
cmdGroup.ShowInDocumentType
cmdGroup.SmallMainIcon
cmdGroup.LargeMainIcon
cmdGroup.SmallIconList
cmdGroup.LargeIconList
cmdGroup.AddCommandItem2 (call multiple times)
cmdGroup.Activate
And removing it when the add-in unloads using:
cmdMgr.RemoveCommandGroup2(groupId, true)
The toolbar/menu are created without any issues. All features on the toolbar function properly.
The issue occurs when you close and restart SolidWorks. The toolbars remember their that they were on for lets say the AssyDoc type. When I restart SolidWorks and open an assembly, they are there.....but have returned to the top left of the window. They do not remember their previously set locations. The key for the toolbar under "HKEY_CURRENT_USER\Software\Solidworks\SolidWorks 2013\User Interface\Custom API Toolbars\59424" is gone - deleted when SolidWorks closes even though I'm passing true as the 2nd arg to RemoveCommandGroup2. And the "HKEY_CURRENT_USER\Software\Solidworks\SolidWorks 2013\User Interface\Toolbars\AssemblyTool\uiCustomApiToolbars_c59424" key is properly set to 1 which is why they are visible when opening an assembly after starting a new session.
However, if I comment out the call to RemoveCommandGroup2, the toolbars remember their locations, but they do not remember if they were on or not for specific document types. So for instance, I can see that the key "HKEY_CURRENT_USER\Software\Solidworks\SolidWorks 2013\User Interface\Custom API Toolbars\59424" does still exist after exiting SolidWorks, but the corresponding "HKEY_CURRENT_USER\Software\Solidworks\SolidWorks 2013\User Interface\Toolbars\AssemblyTool\uiCustomApiToolbars_c59424" key is set to 0 instead of 1. So when you relaunch SolidWorks, you have to turn the toolbars back on every session. But they do turn on in the right location.
Any ideas how I can resolve this so these custom toolbars remember their visibility state AND location between session? I'm updating an add-in that used to use AddToolbar4. But for other reasons, I'd prefer to use the command manager.
Thanks in advance,
- Nick
SolidworksApi macros