Objective Toolkit : Chapter 30 Introduction to Objective Toolkit for ATL : Internet Explorer Band Object Wizard and Classes
Internet Explorer Band Object Wizard and Classes
The Internet Explorer extensibility model allows you to create visible COM objects that inhabit the browser frame, or the enhanced desktop taskbar. OTL provides implementations of IDeskBand and other shell interfaces needed to accomplish this integration. The OTL band Object Wizard can generate a generic band object for any of the three possible types:
Desk Band
Docked in the Windows Taskbar on the desktop
Explorer Band (Vertical Explorer Bar)
Docked in the left side of the browser.
Communications Band (Horizontal Explorer Bar)
Docked in the bottom edge of the browser
From a development perspective, the differences among these types are minor. In fact, the only difference among types is the registry category and default size. The wizard-generated COM object is also a window you can draw your UI onto by handling WM_PAINT messages. Your band object window can contain child windows or whatever user interface you choose.
Changing Size Constraints
Window size limits are controlled by the m_bandInfo member of OtlIDeskbandImpl. m_bandInfo is a DESKBANDINFO structure, which holds the minimum, maximum, integral change and ideal sizes for the band object window. These members can be modified directly in your derived class constructor.
Context Menu Commands
A band object can have context menu commands that appear when the window is right-clicked. OTL supports this through the OtlIContextMenuImpl base class. Menu commands can be conveniently handled in your message map as WM_COMMAND messages. By default, the band Object Wizard adds one custom context menu command handler to the object. The menu handlers are declared in an OTL command map. The command map supplies the menu item text, help string, and a command ID for the menu item.
The code below shows a default command map generated by the band Object Wizard, containing a single command:
 
OTL_BEGIN_COMMAND_MAP()
OTL_COMMAND(_T("&Sample command"), _T("Help string"), ID_SAMPLE_COMMAND)
OTL_END_COMMAND_MAP()
Context menu commands are added from top to bottom when the menu is invoked. You can use the command map macros to create the context menu items that you want to add. A context menu command adheres to the following form:
 
OTL_BEGIN_COMMAND_MAP( )
OTL_COMMAND_ID(UINT ID_COMMAND, UINT ID_HELP )
OTL_COMMAND(LPCTSTR strCommand, LPCTSTR strHelp , UINT ID_COMMAND )
OTL_END_COMMAND_MAP( )
The command map entries can be either OTL_COMMAND or OTL_COMMAND_ID or a mix of both. The choice depends on whether the menu strings are defined in resources or string literals.
Parameters
ID_COMMAND
A resource ID identifying the string resource that is the menu item text. This is also the command ID that is sent in the OtlIContextMenuImpl::FireCommand() function. Override this function to handle a menu item or use OtlIContextMenuMsgImpl, which overrides FireCommand() to generate WM_COMMAND messages to your window.
ID_HELP
A resource ID identifying the string resource that is the help text for the menu item. Can be zero if no help string is available.
strCommand
The string that appears on the context menu.
strHelp
The help string for the menu item. If no help string is needed, use _T("").
This map can be used in conjunction with either OtlIContextMenuImpl or OtlIContextMenuMsgImpl to build context menu extensions. If your object has a window, OtlIContextMenuMsgImpl transparently converts your ID_COMMAND IDs to WM_COMMAND messages that can then be handled in your message map like standard command messages. By default, band objects use OtlIContextMenuMsgImpl and WM_COMMAND handlers for context menu additions.