Auto load/unload a toolbar and menu when a plug-in is loaded/unloaded

Hi friends,

  I define toolbar and menu items in .rui file. I want to show the toolbar and menu item after the plug-in is loaded, and remove the menu item if the plug-in is unloaded.
 How would I do it?

Rhino’s toolbar functions can be found in RhinoSdkUiFile.h. Although the file is not documented, it should be clear what static functions you need to call to open and close a toolbar file. Let me know if you find otherwise.

When opening a toolbar, you will want to do this in your plug-ins’s CRhinoPlugIn::OnLoadPlugIn() override.

When closing a toolbar, you will want to override CRhinoPlugIn::OnSaveAllSettings and do the unloading in this function.

Dale, thank to your reply.

There is a problem that I am using C# to code functions, not C++. However, with your suggestion, I override the function Rhino.PlugIns.LoadReturnCode OnLoad(ref string errorMessage) to load and display the toolbar through ToolbarFileCollection.Open() and ToolbarGroup.Visible. Hope it is the correct steps. Now, the toolbar is display once the plug-in is loaded.

Dale, now the toolbar is visible, but the popup menu is still not appeared. How would I make the popup menu display one the plug-in is loaded.