如何获取所有打开的App Designer应用程序的句柄(uifigures)? [英] How to get the handles of all open App Designer apps (uifigures)?

查看:906
本文介绍了如何获取所有打开的App Designer应用程序的句柄(uifigures)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相关答案中所述,可以使用以下方法获取所有未处理图形的句柄:

As mentioned in a related answer, it is possible to get the handles of all open figures using:

hFigs = findall(groot, 'Type', 'figure');

但这会导致同时包含旧" figure和新" uifigure句柄的列表.

but this results in a list that contains both "old" figure and "new" uifigure handles.

如何将hFigs分为两个列表,一个包含仅 figure的列表,另一个包含 uifigure的引用?

How can I separate hFigs into two lists, one containing only figure and the other only uifigure references?

推荐答案

要以编程方式区分figureuifigure对象,我们可以对我建议的内容

To distinguish between figure and uifigure objects programatically, we can use a slight adaptation of what I suggested here:

function tf = isUIFigure(hFigList)
  tf = arrayfun(@(x)isstruct(struct(x).ControllerInfo), hFigList);
end

建议在拨打上述电话之前先关闭一些警告,例如

It's advised to have a couple of warnings turned off before calling the above, e.g.

% Turn off warnings:
ws(2) = warning('query','MATLAB:structOnObject');
ws(1) = warning('query','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
for indW = 1:numel(ws)
  warning('off', ws(indW).identifier);
end
% Call function:
tf = isUIFigure(hFigs);
% Restore the warnings' state:
warning(ws);

并得出结论:

hFigs = findall(groot, 'Type', 'figure');
isUIF = isUIFigure(hFigs);
hNewFigs = hFigs(isUIF);
hOldFigs = hFigs(~isUIF);

此解决方案已在R2017a和R2017b上进行了测试.

This solution was tested on R2017a and R2017b.

这篇关于如何获取所有打开的App Designer应用程序的句柄(uifigures)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆