get handle of an running gui

30 vues (au cours des 30 derniers jours)
Adrian
Adrian le 18 Sep 2013
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 commentaires
Frank Herzog
Frank Herzog le 19 Juil 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 le 19 Juil 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.

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (1)

Róbert Kakonyi
Róbert Kakonyi le 17 Juil 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.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by