Outlook 2003 Incompatibility with CommandBar Buttons

J

Jim

Hello,

My Add-In works great under Outlook 2000. But when I operate it under
Outlook 2003, my CommandBar buttons behave very differently.

When the user changes the current selection in the Inbox, I set
objButton.Enabled to True or False for each of my buttons to enable or
disable the buttons as appropriate for the current Inbox selection.

This works under Outlook 2000 -- the various buttons on my CommandBar
change states instantly as the user navigates through items in the
Inbox. But under Outlook 2003, a button is not updated unless I hover
over the button with the mouse during the button update by the Add-In,
and then move the mouse pointer off of the button.

Something fundamental has changed with Outlook 2003 CommandBar
buttons. Oddly, if I undock my CommandBar and let it float, my buttons
*are* properly updated as Inbox items are selected. But I must
achieve the same button response for the typical user configuration
where my CommandBar is docked in Outlook.

Outlook 2003 does what I need with its own CommandBar. If you
alternate selection between an Inbox item and the Outlook 'Date:
Yesterday' group heading, three buttons (Reply, Reply to All, and
Forward) on the Outlook CommandBar visibly alternate between enabled
and disabled states exactly as I need (and have working under Outlook
2000).

What has changed in Outlook 2003? How do I make this work?

Thanks.

Jim
 
J

Jim

When I had a similar problem with buttons not updating under Outlook
2000, I added code that rewrote the button Caption (unmodified), and
that forced a repaint of the button:

If blnUpdated = True Then
Dim strCaption As String
strCaption = objButton.Caption
objButton.Caption = strCaption
End If

It looks to me like Outlook 2003 (or the WinXP VB6 VM?) is smarter,
and if the application writes an identical Caption value, the button
is not repainted.

If I alter the Caption by adding a character, the button repaints as
under Outlook 2000. But of course this changes the Caption, the
button width, and ergo the CommandBar width. The result is visible
CommandBar jitter.

I tried temporarily adding and removing an ampersand (denoting hotkey)
so the Caption would change without affecting the button width, but
this did not trigger a repaint. It seems like it should have, since
the hotkey value would need to be visibly underlined in the button
Caption. But it didn't.

I tried briefly increasing the button Width by one programmatically,
and this triggered a repaint. But the increase in CommandBar width due
to all the buttons being wider briefly still produced noticable
CommandBar width jitter. To minimize this, I added code (below) to
alternately add or subtract one to/from the button Width. This still
triggered the desired repaint, and minimized the overall CommandBar
width jitter.

But what a kludge.

Since reading the button Caption and rewriting it to the button no
longer forces a button repaint under Outlook 2003 as it did under
Outlook 2000, what is the best way to force a repaint? There must be
a better way than this kludge.

Thanks.

Jim

If lngOutlookVersionMajor >= OUTLOOK_2003_VERSION_MAJOR Then
If blnUpdated = True Then
Static blnToggle As Boolean
Dim lngWidth As Long
lngWidth = objButton.Width
If blnToggle = True Then
objButton.Width = lngWidth + 1
blnToggle = False
Else
objButton.Width = lngWidth - 1
blnToggle = True
End If
objButton.Width = lngWidth
End If
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top