0
votes

I am using Ribbon XML and VS 2010 to build some custom button controls to Outlook 2010, but having some problem refreshing the state of the buttons.

I created 2 buttons for idMso="TabReadMessage" (Reading email window/inspector).

Ribbon XML code for the buttons:

<tab idMso="TabReadMessage">
  <group id="MyGroup" label="My Label">
     <splitButton id="MySplitButton" keytip="QS" size="large">
          <button id="SplitButton1" onAction="SplitButton1_Click" label="SplitButton 1" />
          <menu id="SplitButton_mnu" keytip="QS">
                <button id="Button1" onAction="Button1_Click" label="Button 1" />
                <button id="Button2" onAction="Button2_Click" label="Button 2"/>
          </menu>
     </splitButton>
     <toggleButton id="MyToggleButton" onAction="MyToggleButton_Click" size="large" label="Toggle Button" getEnabled="GetEnabledToggleButton" />
  </group>
</tab>

Split button click callback:

Public Sub SplitButton1_Click(ByVal control As IRibbonControl)
   ribbon.InvalidateControl("MyToggleButton")
End Sub

Toggle button getEnabled callback event:

Public Function GetEnabledToggleButton(ByVal control As IRibbonControl) As Boolean
   Return False
End Function

What I want to achieve is that after I click on the SplitButton, the ToggleButton will be disabled, I am using ribbon.InvalidateControl("MyToggleButton") to invalidate the control and this should fire the getEnabled callback event for the ToggleButton, but it didn't. But if I click away from the inspector window and click in again to the inspector window, the state will change and work. I thought InvalidateControl() will change the state of the control immediately?

Please help, thanks.

1

1 Answers

0
votes

I create a subroutine in the Addin class, in this subroutine I invalidate the MyToggleButton control.

The SplitButton1_Click() event will call the subroutine, thus will invalidate the MyToggleButton control, this work, but not sure whether there is a better/recommended way to do this.