Advanced Office 2010 - 2000 task panes:
VB.NET, C#, C++

Add-in Express™
for Microsoft® Office and .net

Add-in Express Home >

Advanced Office 2010 - 2000 task panes

Add-in Express empowers Microsoft Office developers with version-neutral advanced task panes for Excel 2000, 2002 (XP), 2003, 2007 and Office 2010. Please see The UI mechanics above for the detailed description of how Add-in Express panes work.

Below you see the list containing some generic terms mentioned in An absolute must-know and their Excel-specific equivalents:

  • <Manager> - AddinExpress.XL.ADXExcelTaskPanesManager, the Excel Task Panes Manager
  • <Item> - AddinExpress.XL.ADXExcelTaskPanesCollectionItem
  • <Form> - AddinExpress.XL.ADXExcelTaskPane

Application-specific features

ADXExcelTaskPane provides useful events unavailable in the Excel object model: ADXBeforeCellEdit and ADXAfterCellEdit.

Keyboard and focus

ADXExcelTaskPane provides an event that may be useful for your Excel add-in. The event is called ADXKeyFilter. It deals with a feature of Excel that captures the focus if a key combination which can be processed by Excel is pressed. By default, Add-in Express panes do not pass key combinations to Excel. In this way, we are assured that the focus will never leave the pane unexpectedly.

To illustrate the feature, imagine that you need to let the user press Ctrl+S and get the workbook saved while your custom pane is focused. In such a scenario, you have two ways:

  • You process the key combination in the code of the pane and use the Excel object model to save the workbook.
  • Or, you send this key combination to Excel using the ADXKeyFilter event.

Besides the obvious difference between the ways, the former leaves the focus on your custom Excel task pane while the latter effectively moves it to Excel because of the focus-capturing feature just mentioned.

The algorithm of key processing is as follows. Whenever a single key is pressed, it is sent to the pane. When a key combination is pressed, ADXExcelTaskPane determines if the combination is a shortcut on the pane. If it is, the key press is sent to the pane. If it isn't, ADXKeyFilter is fired and the key combination is passed to the event handler. Then the event handler specifies whether to send the key combination to Excel or to the pane. Sending the key combination to the pane is the default behavior. Note that sending the key combination to Excel will result in moving the focus off the pane. The above-said implies that the ADXKeyFilter event never fires for shortcuts on the pane's controls.

Also, ADXKeyFilter is never fired for hot keys ({Alt} + an {alphanumeric symbol}). If ADXExcelTaskPane determines that the pane cannot process the hot key, it sends the hot key to Excel, which activates its main menu. After the user has navigated through the menu by pressing arrow buttons, Esc, and other hot keys, opened and closed Excel dialogs, ADXExcelTaskPane will get focus again.

Wait-a-little and focus again

The Advanced Exel Task Pane provides a simple infrastructure that allows implementing the wait-a-little schema: the ADXPostMessage method and the ADXPostMessageReceived event.

Currently we know at least one situation that this trick is required. Imagine that you show a custom task pane and you need to set the focus on a control on this pane. It isn't a problem to do this in, say the Activated event. Nevertheless, it is useless because Excel, continuing its initialization, captures the focus off the pane. With the above-said method and event you can make your custom Excel task pane look like it never loses focus: in the Activated event handler, you call the ADXPostMessage method specifying a unique parameter set and, in the ADXPostMessageReceived event, you check for that parameter set; when you get the appropriate ADXPostMessageReceived event, you set the focus on the control. Here we are! Beware, there will be a huge lot of inappropriate messages in the ADXPostMessageReceived event.