get handle of an running gui

31 Ansichten (letzte 30 Tage)
Adrian
Adrian am 18 Sep. 2013
Beantwortet: Róbert Kakonyi am 17 Jul. 2019
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 Kommentare
Frank Herzog
Frank Herzog am 19 Jul. 2018
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 am 19 Jul. 2018
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Sep. 2013
Possibly
findobj(0, 'tag', 'GUI1')
or
findobj(0, 'type', 'figure')
and exclude from that the figure(s) associated with GUI2.
  3 Kommentare
Walter Roberson
Walter Roberson am 20 Jul. 2018
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 am 24 Jul. 2018
Using findall() instead of findobj() solved the problem. Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Róbert Kakonyi
Róbert Kakonyi am 17 Jul. 2019
>> 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.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by