I would like to use the full range of Add-In CommandBar features which are only partially implemented in Add-Ins under VB6.
Since this is a poorly documented area in the MSDN, and very few people are building add-ins (judging by the limited number of relevent questions on EE) I will provide a bit of back ground.
VB Add-Ins and Add-Ins for Microsoft Office (Word, Excel, etc.) allow for programmer defined CommandBars which are similar to VB Toolbars but appear to be implemented differently.
To create them in a VB Add-In we include a reference to Microsoft Office 8.0 Object Library (I'm using VB6 with Office 97 under Win 98SE) along with the Microsoft Visual Basic 6 Extensibility reference.
The CommandBar theoretically provides for a large variety of different button types which we see implemented in the standard VB IDE and the Office suite. These are enumerated and can be seen with the Object Browser under the Office object MsoControlType key. In practice, Microsoft restricts the programmer to 3 button types (at least thats all I have been able to implement):
msoControlButton: a basic button with a 16x16 bitmap button face
msoControlPopup: a text caption with a down arrow (no optional image as far as I can tell)
msoControlComboBox: a standard drop-down combo
An example of one I would dearly love to implement is msoControlSplitButtonMRUPo
pup. This is used in the VB IDE Form Editor Toolbar with the "Align", "Center", etc. buttons.
As for what I would specifically like to do:
1) Implement the msoControlSplitButtonMRUPo
pup style button (or at least an image and a down arrow without the split), and
2) Create a VB "look-alike" button/bar customization mechanism (what you see and can do when you right click an IDE toolbar, select "Customize...", and the "Commands" Tab).
The latter requires drag/drop of buttons, bar position indicators (where button will be dropped), a selection box around the currently selected button, etc.
Full points will be awarded only for "Full Code" solutions (or links to same).
In case of partial solutions - I will award 500 points for the first (msoControlSplitButtonMRUP
opup implementation), and 1000 points for the second.
I don't care how it is implemented (within reason) but would prefer it be the "natural" extension of the capabilities that MS gave us. I.E what they are clearly using but have chosen not to document. The next best solution would be the ability to subclass or hook the CommandBar and do a "user drawn" CommandBar. Possibly acceptable solutions could include timer driven "hacks" so long as they don't consume a lot of cpu resources and are flicker free. Unacceptable solutions are those that require Commercial software such as Desaware SpyWorks.
For a "quick start" simple Add-In" sample see Planet Source "Track Code Changes"
This sample uses a single button on a standard VB IDE CommandBar. In my case I want a custom multi-button CommandBar, but the basic Add-In techniques are the same.
Note that CommandBars have standard window handles (hWnd) just like VB Toolbars so we have at least that much to work with.
Some things I've tried, but couldn't get to work (which doesn't mean they won't - maybe I screwed up):
Given the possibility (fairly remote I think) that the CommandBars use ComCtl32.Dll (as do VB Toolbars), I started with a simple example from VBNet (http://www.mvps.org/vbnet/
) "Changing a VB Toolbar to a Rebar-Style Toolbar". This sample uses ComCtl32.Dll and the API to modify VB toolbar styles. When I used a CommandBar hWnd I got back a "0" response to the TB_GETSTYLE message so I abandoned this possibility.
Toolbar sub-classing: vbAccelerator (http://vbaccelerator.com/
) contains numerous samples of "user drawn" controls (including VB toolbars) using the authors SSubTmr6.DLL subclasser. With this particular subclasser (and all freeware ones I know of) you are limited to subclassing controls that are part of your VB program. When I attempted to subclass a CommandBar I get the SSubTmr6 error message "Can't modify external window"
Thanks for any help. Lets see if we can make some advances in this poorly documented and under-utilized capability.
(Why won't EE let me post greater than 300 points? - no points for an answer to this - I know it could be done in the past)