get handle of an running gui

31 ビュー (過去 30 日間)
Adrian
Adrian 2013 年 9 月 18 日
回答済み: Róbert Kakonyi 2019 年 7 月 17 日
Hi,
I have a GUI (GUI2) and want to get the handle of another one (GUI1) which is already running behind the actuall GUI-Window. If I use GUI1handle = guidata(GUI1) I get the handle but the Window behind opens again. How can I solve this?
  2 件のコメント
Frank Herzog
Frank Herzog 2018 年 7 月 19 日
The accepted answer to this question does not work for versions R2017a and R2017b. The return value of both calls is a '0x0 empty GraphicsPlaceholder array', i.e., not a handle to the gui window.
How can I obtain a valid handle to a gui window in R2017a or R2017b?
Dennis
Dennis 2018 年 7 月 19 日
The first call can only work if you actually set a tag to your figure/object.
The 2nd works without any problem for me (2017b).
You could aswell just store and pass the handle when you create your figure.
It might also be a good idea to open a new question - this one is 5 years old and probably does not receive too much attention nowadays.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2013 年 9 月 18 日
Possibly
findobj(0, 'tag', 'GUI1')
or
findobj(0, 'type', 'figure')
and exclude from that the figure(s) associated with GUI2.
  3 件のコメント
Walter Roberson
Walter Roberson 2018 年 7 月 20 日
Both approaches work in HG2.
However, if you are using GUIDE then the handle visibility of your GUI might be set to 'callback'. If it is, then you will need to use findall() instead of findobj()
Frank Herzog
Frank Herzog 2018 年 7 月 24 日
Using findall() instead of findobj() solved the problem. Thanks!

サインインしてコメントする。

その他の回答 (1 件)

Róbert Kakonyi
Róbert Kakonyi 2019 年 7 月 17 日
>> hGUI = findobj(0)
>> hGUI.ShowHiddenHandles = true
>> hGUI = findobj(0)
hGUI =
236×1 graphics array:
Root
Figure (figure1)
UIControl (text171)
UIControl (pb_input_data)
UIControl (pb_skizze_vor
... and a lot more.
>> hfig = hGUI(2);
>> hfig.delete;
This will delete the seemingly locked object.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by