简体   繁体   English

检测图库是否在Windows Ribbon框架中打开

[英]Detect if gallery is open in Windows Ribbon Framework

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. 我正在使用实现IUICollection的Delphi Ribbon Framework。 I tried several properties using IUIFramework.GetUICommandProperty (eg UI_PKEY_Viewable, UI_PKEY_Enabled), but neither of these returns the "open/closed" state of the gallery dropdown. 我使用IUIFramework.GetUICommandProperty尝试了几个属性(例如,UI_PKEY_Viewable,UI_PKEY_Enabled),但这些属性均未返回图库下拉列表的“打开/关闭”状态。

Does anyone know if this is possible at all? 有人知道这是否可能吗?

I was able to work around this by using the IAccessible interface. 通过使用IAccessible接口,我可以解决此问题。 (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd318466(v=vs.85).aspx ) (请参阅https://msdn.microsoft.com/zh-cn/library/windows/desktop/dd318466(v=vs.85).aspx

Fortunately, we already had functionality for finding specific UI elements. 幸运的是,我们已经具有用于查找特定UI元素的功能。 It uses AccessibleObjectFromWindow; 它使用AccessibleObjectFromWindow; from the unit Winapi.oleacc , to retrieve an IAccessible object from the main applications window handle. Winapi.oleacc单元中,从主应用程序窗口句柄中检索IAccessible对象。

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. 从那里开始,它使用AccessibleChildren递归检查子项,如此处所述: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/dd317975 (v= vs.85).aspx并比较当前具有给定参数的元素名称。

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. 该项目仅在画廊开放时可用,因此使用我们自定义的“ FindElement”功能,我可以区分可见的弹出窗口和关闭的弹出窗口。

This might not be the nicest solution, but I'm afraid there is no other... 这可能不是最好的解决方案,但恐怕没有别的...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM