none
Outlook, C++ ATL, HWND of the Ribbon ? (Microsoft.Outlook.Explorer) RRS feed

  • Question

  • Hi,

    I have custom buttons in my Outlook Addin and I want to load the labels of the buttons dynamically.(to support several langages)

    I need the HWND of the Ribbon (Microsoft.Outlook.Explorer) because I want to do a call to HWND h1 = GetDlgItem( HWNDRIBBON,IDC_BUTTON); and then a call to ::SetWindowText(h1,)

    How to get the HWND of the Ribbon ?


    • Edited by stephane_l2 Thursday, August 27, 2015 1:41 PM
    Thursday, August 27, 2015 1:40 PM

Answers

All replies

  • I think you need to use one of the callback functions to dynamically set a label.  Check out the getLabel callback.

    Customizing the 2007 Office Fluent Ribbon
    • Edited by RLWA32 Thursday, August 27, 2015 1:49 PM
    • Marked as answer by stephane_l2 Thursday, August 27, 2015 3:52 PM
    Thursday, August 27, 2015 1:46 PM
  • Hello Stephane,

    What custom button labels/text do you need? Does it belong to your add-in?

    You can cast an instance of the Explorer or Inspector window to the IOleWindow interface and use the GetWindow method which allows to retrieves a handle to one of the windows participating in in-place activation (frame, document, parent, or in-place object window).

    If controls come from your add-in you may consider using callbacks for getting the labels text.
    Thursday, August 27, 2015 1:53 PM
  • Thank you RLWA32.

    as the first parameter of the callback getlabel is a [in] IRibbonControl * , how can  I get the ID of the control, to decide which string to write in the second parameter (a BSTR*)? 

    Thursday, August 27, 2015 2:02 PM
  • Stephanie,

    You should already know the ID of the control from the XML that defines your custom button on the ribbon.  In order to get Outlook to update it, you would use the IRibbonUI interface to call InvalidateControl on the button you want to update

    Thursday, August 27, 2015 2:13 PM
  • I had not seen the documentation, there is a method of IRibbonCOntrol to get the id.
    Thursday, August 27, 2015 2:13 PM
  • Thank you eugene and rlwa32 I will try to make the things with getlabel....I need only to load the label at the loading of the plugin (I want only to support multilingal interface)
    Thursday, August 27, 2015 2:16 PM
  • You can have multiple versions of the XML that defines your custom buttons on the Ribbon with each one using a different language.  Storing the XML as a resource works well for this.  Then you can return the specific one that you want when the addin loads by specifying it in the GetCustomUI function.

    • Edited by RLWA32 Thursday, August 27, 2015 2:21 PM
    Thursday, August 27, 2015 2:20 PM
  • There is no need to store different versions of the XML markup. Appropriate values can be assembled at runtime when Office requests the ribbon XML.

    Or Ribbon callbacks can be used to specify localized values - there is no need to use different XML versions at all!

    Thursday, August 27, 2015 2:25 PM
  • Yes  I think I prefer the getlabel callback solution, I make the things like that and come back here, as soon as it runs!!
    Thursday, August 27, 2015 2:30 PM
  • There is no need to store different versions of the XML markup. Appropriate values can be assembled at runtime when Office requests the ribbon XML.

    Or Ribbon callbacks can be used to specify localized values - there is no need to use different XML versions at all!


    That's just a matter of personal choice
    Thursday, August 27, 2015 2:41 PM
  • That is efficiency, not choice. 
    Thursday, August 27, 2015 2:45 PM
  • If you say so
    Thursday, August 27, 2015 2:46 PM
  • I have just a little problem : I have already a loadImage callback and I have written in the xml :

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="OnLoadImage" getLabel="OngetLabel">

    and it says there is an error with getlabel:it says getLabel is not defined in the DTD schema

    Thursday, August 27, 2015 2:57 PM
  • Stephane,

    The customUI element can't contain the getLabel attributes according to the Ribbon schema.

    The Ribbon UI is described in depth in the following series of articles in MSDN:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    There you can find all the possible attributes described.

    Thursday, August 27, 2015 2:59 PM
  • thank you eugene, I have put it in the tab but it seems the signature on the microsoft web page is not good anymore, because it says it does'nt find the callback and I had this error before, with OnLoadImage when the signature was not good.
    Thursday, August 27, 2015 3:14 PM
  • I have put this signature :HRESULT GetLabel([in] IRibbonControl *pControl, [out, retval] BSTR *pbstrLabel)

    Thursday, August 27, 2015 3:16 PM
  • You have to define a corresponding callback for the getLabel attribute in the code-behind files.
    Thursday, August 27, 2015 3:33 PM
  • I had this error because I only made the mistake to put a white space in the signature in the _i.h file,after the [in] and [out].

    Now I deleted the white spaces and it loads my label,but I have put the getlabel= in each button and in the group and in the tab in the xml file.

    but now it is ok.my problem is solved.(I didn't try with another langage but it runs with the french langage so I suppose it's ok)

    • Edited by stephane_l2 Thursday, August 27, 2015 3:51 PM
    Thursday, August 27, 2015 3:49 PM
  • thank you both.....
    Thursday, August 27, 2015 3:49 PM