PowerVB Type Library Editor Overview


The PowerVB Type Library Editor control is used in all of the type library editing tools provided with Advanced Visual Basic 6: Power Techniques for Everyday Programs. Editing elements in a type library is essentially the same regardless of the exe/add-in that the control is hosted in. The editing operations fall into two categories, those done by editing fields in the right-hand side of the control, and commands executed from the context menu in the tree control. This document explains the context-menu commands for each type of selection.

There are four types of nodes in the type library editor: Library, Type, Member, and Parameter. Each of these node types have distinct commands. There are also settings menu items, which are offered on the context menu for all node types.

You will find a handful of standard keystrokes will greatly increase your editing productivity. Observing Windows users has made it obvious that many are not familiar with these key sequences, so I'll mention them here. The most important key is the context-menu key, located on most keyboards to the immediate left of the right control (Ctrl) key. Using this key is equivalent to right-clicking on the currently selected item and will eliminate the need for the mouse in most editing operations. The second keystroke is F2 in a treeview, which opens a label for editing. The third keystroke is the left arrow key in a treeview, which collapses an expanded node or moves to the parent if the selection is on a leaf node. The type picker dialog opens with a selection on an expanded leaf node. Two left-arrow keystrokes will collapse the newly opened dialog to an unexpanded list of libraries. If you're picking a type in a different library, the double-left-arrow sequence is much more efficient than using the up arrow. With these simple keystrokes, you should be able to do most of your type library editing without touching a mouse.

Note that all commands in the core type library editing control can be filtered by the host program, so not all commands will appear in all environments. Similarly, fields and options in the right pane will be read-only in some cases. For example, the PowerVB Binary Compatibility Editor heavily constrains the available commands to stop you from adding items to the type library that VB cannot reproduce. If you cannot see a command then it is either filtered out or not available on the current selection. To reduce clutter, any command that is not available is simply omitted from the context menu instead of being shown in a disabled state.

The fields in the right hand editing pane are generally self-explanatory (especially if you reference the IDL/ODL discussions in MSDN to see what all the attributes mean), but a few tips are still in order. The right-hand pane offers several editing fields, and there are several common editing operations that require several of these fields to be in sync. For example, if you change the type of a constant from long to BSTR, then the value of the constant must be changed to a number. Because of this multi-field nature of many edits, edits in the right-hand pane will lock the selection in the tree and force you to either Update or Cancel the edit before proceding. The active edit state applies even to single-field edits: you must either Update the library or Cancel the edit before continuing. Hitting the Enter key with an active edit will commit the change and move the focus back to the tree.

There are several semi-hidden features in the editing pane.
    -Double-clicking a GUID or type field is equivalent to hitting the ellipsis button to the right of these fields.
    -The context menu for the constant edit field can be adjust to display either hexadecimal or decimal. You can prefix a number with &H to enter a hex value at any time, but it will be listed back as decimal when you update unless you change the display format with the context menu.
    -The MemberID field also offers decimal/hexadecimal display format options on the context menu. Generally, you will want to keep the default options here, which show positive IDs in hex and negative IDs in decimal.
    -If the type field shows a type with a library qualifier, such as 'Excel.Worksheet', then a context menu is available on this field that lets you internalize and redirect this type. These commands are also available with the Internalize Types command and the External Types dialog on the Library node.