How to retrieve items information from Windows 7 Ribbon

Answered How to retrieve items information from Windows 7 Ribbon

  • Thursday, June 18, 2009 12:48 PM
     
     
    Hello all,

    I try working with the Windows 7 Ribbon Framework, but cannot find a way to retrieve information about the current state of framework controls. Maybe, somebody knows answers to the following questions:
    1. How do I retrieve the ribbon controls collection? (for example, the ribbon Tab-objects collection, the Group objects collection for a specified Tab, etc.)
    2. How do I retrieve the Command associated with every ribbon control in the control collection?
    3. How do I retrieve Command properties (Id, Name, Comment...)?
    4. How do I retrieve the client coordinates of the onscreen rectangle of every visible ribbon control (Button, CheckBox, ...)?
    5. How do I determine what control is placed under the client point (hit-test)?
    6. How do I get IUIRibbon by using the ribbon window handle (for example, UIRibbonCommandBar's HWND)?

    These problems do not allow using Ribbon controls in our application.

All Replies

  • Friday, July 17, 2009 5:49 PM
    Owner
     
     Proposed

    Could you describe your scenario in more detail?

    It's not clear from your questions what you are trying to accomplish. Are you building an accessibility application or a Ribbon application that requires this information at run time? If it's the latter then most, if not all, your questions are answered in the documentation at http://msdn.microsoft.com/en-us/library/dd371191(VS.85).aspx.

    Please clarify and I'll try to answer your questions.


    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Wednesday, July 29, 2009 6:35 AM
     
     
    We're trying to build an application designed for testing of Ribbon applications. We tried to use IAccessible, but the interface doesn't provide all needed data. We tried to use the interfaces described in the documentation (http://msdn.microsoft.com/en-us/library/dd371191(VS.85).aspx), but they do not provide the whole volume of the needed data either. These two methods didn't allow us to get the data I mentioned in my first post.

    Thanks for your time anyway.
  • Friday, August 07, 2009 9:56 PM
    Owner
     
     
    The Ribbon framework implements Microsoft Active Accessibility (MSAA).

    For more information on accessibilty in the Ribbon framework, see Working with Active Accessibility in the 2007 Office Fluent User Interface (http://go.microsoft.com/fwlink/?LinkID=157256).
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Friday, August 14, 2009 1:02 PM
     
     
    MSAA does not provide all the needed data, it does not give access to all of the properties of the Ribbon items.

    Thanks for your attention.
  • Tuesday, November 17, 2009 8:01 AM
     
     Answered

    1. You can use the Accessibility interfaces to get the controls as windows objects, see Obtaining UI Automation Elements, so you can figure our the ribbon structure, but can't access ribbon properties from there. You can't retrieve ribbon controls collection using ribon API.

    2. You can't since there is no direct connection between ribbon control window and the attached command ID.

    3. Using IUIFramework::GetUICommandProperty you can get command properties. However, ID is the identifier of the command, so you can't really get it, you have to provide it to get the other properties. Also, I believe the Name and Comment properties are not available after compilation so no chance of getting them. Use GetUICommandProperty to get ribbon properties like Label, Tooltip, LargeImage, etc.

    4. This information is provided using the Accessibility interfaces. After you have the AutomationElement of your ribbon control, you can query (GetCurrentPropertyValue) the BoundingRectangleProperty.

    5. Using AutomationElement.FromPoint to get the AutomationElement of the underlying control.

    6. I don't think you can.
  • Tuesday, May 17, 2011 2:42 PM
     
     

    can you provide an example of GetUICommandProperty ?

    Everytime I call it, on any object, I always get back 0x80070032, "The request is not supported". 

    I'm working with the DropDownColorPicker sample in the Windows 7 SDK WindowsRibbon samples. I put this in all the command handler execute methods just to test. and every one comes back with 0x80070032

     

    PROPVARIANT myLabel ;

    HRESULT hr = g_pFramework->GetUICommandProperty(nCmdID, UI_PKEY_Label, &myLabel) ;