After I posted my source for managing CommandBarButton and CommandBarPopup objects I received a few requests to include management of CommandBarButtons that control the state of AnchorBar windows.
As you know you can add your own windows within the Visio drawing window, similar to the Shape Data window. These type of windows are typically controlled via a menu item that toggles its state or caption depending on the visible state of the window. For example, the caption of the menu item changes or the visual state or the menu item switches between a pushed or unpushed state.
Good news. I updated my CommandBar management code to support this functionality.
Included in this update is my new VisioCommandBarButtonForAnchorWindow class. This new class contains the functionality for toggling either the Caption property or the State property of the CommandBarButton based on the Visible state of your AnchorBar window.
After you download this source you should be able to compile it and run it. You will need VS 2008, VSTO 3.0, and Visio 2007. Visio 2007 will also need to have .NET Programmability Support installed (PIA).
Feel free to add the UIMgr.cs and the VisioCommandBars.cs source files to your own project. In most cases all you will need to do is change the AddUI method to add your specific CommandBarButtons or PopUps.
Click here to download the sample VSTO based add-in that demonstrates how these wrapper classes are used, along with the full source to the wrapper classes.