none
Custom ribbon won't refresh for each new inspector RRS feed

  • Question

  • Hello,

    I'm Working on a XML custom ribbon on outlook 2010.

    I use getLabel to name a button on new inspector window, that name would change depending on the content of the active mail item

    My problem is that the ribbon is not refreshed each time a new inspector opens, so the the button name will remain the same

    How can I force the robbon to reload ?

    I've tried using ribbon.Invalidate (maybe not correctly) and all the open inspectors were affected with the same updated value, not just the active inspector.

    Hoping this is clear enough, thank you for your help

    Thursday, September 15, 2011 2:45 PM

Answers

  • At class level:
     

        Private WithEvents m_objInsp As Outlook.Inspector = Nothing

    The event handler:

        Private Sub m_objInsp_Activate() Handles m_objInsp.Activate


    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:b3e7792c-2109-4569-821e-da5b468eef9b...
    "NewInspector() is not the time to call Invalidate(), as you only have a weak object reference to the Inspector and its current item at that time. You should call that method in the first Inspector.Activate() event that fires for the new Inspector."
    Sorry, I just can't find correct VB.net syntax on how to handle activate event - would you provide a sample please
    Thank you
     
     

    Ken Slovak MVP - Outlook
    • Marked as answer by Support BOSSARD Wednesday, September 21, 2011 3:16 PM
    Tuesday, September 20, 2011 3:55 PM

All replies

  • When you use Invalidate() that will force the getLabel callback, you then need to apply your change only to the Inspector you want.
     
    In the callback you get an IRibbonControl control object passed to you. If you use control.Context that will be the Inspector that the callback instance is related to. You can grab the Inspector caption or other distinguishing characteristic before you call Invalidate() and check that in the callback to only change the label on the desired Inspector window.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:d2143f64-49a9-4697-806d-eae4f0effcc4...

    Hello,

    I'm Working on a XML custom ribbon on outlook 2010.

    I use getLabel to name a button on new inspector window, that name would change depending on the content of the active mail item

    My problem is that the ribbon is not refreshed each time a new inspector opens, so the the button name will remain the same

    How can I force the robbon to reload ?

    I've tried using ribbon.Invalidate (maybe not correctly) and all the open inspectors were affected with the same updated value, not just the active inspector.

    Hoping this is clear enough, thank you for your help


    Ken Slovak MVP - Outlook
    Thursday, September 15, 2011 5:48 PM
  • Ken,

    Thank you for your reply, the control.Context works OK to be compared to active inspector when tested inside the getLabel callback, but it's not the correct place to call Invalidate(), right ?

    Now I want make the test out of the getLabel callback to call or not Invalidate(), but then how to access the IRibbonControl control object ?

     

    Thank you for your help


    Friday, September 16, 2011 1:07 PM
  • What I do is to call Invalidate() in the Inspector.Activate() event.
     
    I set up a Boolean flag, _startup, that's set to true in NewInspector(). When the Activate() event fires I check _startup and if true I call Invalidate() (and then set the flag to false). That sets up the Inspector with the label, image tooltip and other properties I want set on that window.
     
    In each callback (getImage, getLabel, etc.) I'd check the Inspector as discussed previously to see what to apply to that Inspector.
     
    Other events can also be used to change or refresh the ribbon, depending on your requirements. For example if you wanted to change a button caption when some other button is clicked you could call Invalidate in that button click event.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:1c9b2d36-b885-4d2c-82d5-9456eec57235...

    Ken,

    Thank you for your reply, the control.Context works OK to be compared to active inspector when tested inside the getLabel callback, but it's not the correct place to call Invalidate(), right ?

    Now I want make the test out of the getLabel callback to call or not Invalidate(), but then how to access the IRibbonControl control object ?

     

    Thank you for your help



    Ken Slovak MVP - Outlook
    Friday, September 16, 2011 1:17 PM
  • Ken,

    Even afer several tries I'm still confused - sorry - here is what I do :


    -thisaddin.vb :
    ...
        Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
            monruban = New MAJ_boutons()
            Return monruban
        End Function
    ...


    -MAJ_boutons.vb (linked to MAJ_boutons.xml/B_Exp is the button with dynamic name)
    ...
        Public Sub maj()
            ribbon.InvalidateControl("B_Exp")
        End Sub


        Public Function B_Exp_Label(ByVal control As Office.IRibbonControl) As String
            Return XXXXXX
        End Function
    ...


    -main
    in new inspector event I check if I need to update the ribbon, if yes I call
    monruban.maj()


    There must be something wrong, where/how should I use Control.Context here ?
    Thanks

    Tuesday, September 20, 2011 6:46 AM
  • NewInspector() is not the time to call Invalidate(), as you only have a weak object reference to the Inspector and its current item at that time. You should call that method in the first Inspector.Activate() event that fires for the new Inspector.
     
    If your ribbon control is "B_Exp", invalidating the control will fire the getLabel, getVisible, getEnabled callbacks (as well as others) that you've set up. In the callback, in this case B_Exp_Label() is providing you with the ribbon IRibboncontrol object "control".
     
    You would use control.Context in any of the callbacks that you've set up.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:2920ea0a-5bbf-4924-a9b7-6212bf8c86c0...
    Ken,

    Even afer several tries I'm still confused - sorry - here is what I do :


    -thisaddin.vb :
    ..
        Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
            monruban = New MAJ_boutons()
            Return monruban
        End Function
    ..


    -MAJ_boutons.vb (linked to MAJ_boutons.xml/B_Exp is the button with dynamic name)
    ..
        Public Sub maj()
            ribbon.InvalidateControl("B_Exp")
        End Sub


        Public Function B_Exp_Label(ByVal control As Office.IRibbonControl) As String
            Return XXXXXX
        End Function
    ..


    -main
    in new inspector event I check if I need to update the ribbon, if yes I call
    monruban.maj()


    There must be something wrong, where/how should I use Control.Context here ?
    Thanks


    Ken Slovak MVP - Outlook
    Tuesday, September 20, 2011 1:24 PM
  • "NewInspector() is not the time to call Invalidate(), as you only have a weak object reference to the Inspector and its current item at that time. You should call that method in the first Inspector.Activate() event that fires for the new Inspector."
    Sorry, I just can't find correct VB.net syntax on how to handle activate event - would you provide a sample please
    Thank you
     
     
    Tuesday, September 20, 2011 3:39 PM
  • At class level:
     

        Private WithEvents m_objInsp As Outlook.Inspector = Nothing

    The event handler:

        Private Sub m_objInsp_Activate() Handles m_objInsp.Activate


    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:b3e7792c-2109-4569-821e-da5b468eef9b...
    "NewInspector() is not the time to call Invalidate(), as you only have a weak object reference to the Inspector and its current item at that time. You should call that method in the first Inspector.Activate() event that fires for the new Inspector."
    Sorry, I just can't find correct VB.net syntax on how to handle activate event - would you provide a sample please
    Thank you
     
     

    Ken Slovak MVP - Outlook
    • Marked as answer by Support BOSSARD Wednesday, September 21, 2011 3:16 PM
    Tuesday, September 20, 2011 3:55 PM
  • At last I could do what I wanted, thanks to your support.

    Thank you very much

     

    Stéphane

     

    Wednesday, September 21, 2011 3:17 PM