Detect if gallery is open in Windows Ribbon Framework

138 views Asked by At

I'm looking for a way to detect whether a ribbon gallery is opened, or not. I'm using the Delphi Ribbon Framework, which implementes IUICollection. I tried several properties using IUIFramework.GetUICommandProperty (e.g. UI_PKEY_Viewable, UI_PKEY_Enabled), but neither of these returns the "open/closed" state of the gallery dropdown.

Does anyone know if this is possible at all?

1

There are 1 answers

0
SaschaSchaefer On BEST ANSWER

I was able to work around this by using the IAccessible interface. (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd318466(v=vs.85).aspx)

Fortunately, we already had functionality for finding specific UI elements. It uses AccessibleObjectFromWindow; from the unit Winapi.oleacc, to retrieve an IAccessible object from the main applications window handle.

From there, it recursively checks the child items using AccessibleChildren, as described here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317975(v=vs.85).aspx and compares the current element's name with a given parameter.

As parameter, I use the caption of the first item in the gallery. This item is only available if the gallery is open, so using our custom "FindElement" functionality, I was able to differenciate between a visible popup, and a closed one.

This might not be the nicest solution, but I'm afraid there is no other...