Missing Button Text & Cached buttons

  • Thread starter Thread starter JahMic
  • Start date Start date
J

JahMic

It seems outlook does some caching of buttons. Even if I remove
buttons from my add-in and reinstall, the old buttons show up.
Resetting the toolbar nukes them all but then on the next restart, all
the old buttons are there, how to get around that?

Also, I think it may be related, but try as I may, my button text is
not showing up. I am roughly creating my buttons like so:

pStandardBar = pInspector->CommandBars->GetItem("Standard");
Office::CommandBarControlsPtr pBarCtrls = pStandardBar->GetControls();

pButton = (Office::CommandBarControlPtr)(spBarCtrls->Add(
(long)Office::msoControlButton,
vtMissing,
vtMissing,
vtMissing,
true));
pButton->Caption = "My Button";
pButton->TooltipText = "My Button tooltip";

// trying...
pButton->PutCaption(OLESTR("My Button text again"));
// trying more...
_bstr_t bstrCaption(OLESTR("My Button text one more time"));
pButton->PutCaption(bstrCaption);
pButton->PutDescriptionText(bstrCaption);

Any ideas?
 
Upon further investigation, I have found this is due to the using Word
an the email editor, as noted many times in this group. However, I
still haven't seen any good workarounds for this. Yes, I can hide my
buttons, but that sort of defeats the point. I think I have seen a
other add-ins with buttons on the WordMail inspector, so there must be
a way... Any ideas?

Thanks, J
 
Word does not honor the Temporary = true argument when you create UI, you
must explicitly delete that UI for it to not be there permanently in
normal.dot or wherever the CustomizationContext is set to.

What I do is create the UI and then I handle the Word events WindowActivate
and BeforeDocumentClose. I get Word from WordEditor.Parent. Once I can
handle those events as well as Inspector.Close, I explicitly delete the UI
when BeforeDocumentClose and Inspector.Close fire. I set a flag to tell if
the UI has already been destroyed.

I use WindowActivate to handle when to show and when to hide my UI. If in
that event handler Window.EnvelopeVisible = true then it's a WordMail
window, otherwise not. So I know when to hide and show the UI. I iterate the
Document.CommandBars collection and look for those that aren't built-in. I
compare the Tag property on the UI object to see if it's one of mine and if
it's for that specific Inspector and if so I show the toolbar, if not I set
Visible and Enabled to true.

When creating, modifying any setting or destroying the UI I immediately set
Word.CustomizationContext.Saved = true so Word thinks no changes were made.
That prevents a prompt to save normal.dot when Word is exiting.

Note that you may have to re-instantiate your UI elements when accessing
them for anything other than a click event, many properties in WordMail UI
objects are not usable except if you do that each time you access them even
if the object itself is not null.
 
Back
Top