get handle of an running gui

28 views (last 30 days)
Adrian
Adrian on 18 Sep 2013
Answered: Róbert Kakonyi on 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 Comments
Frank Herzog
Frank Herzog on 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 on 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.

Sign in to comment.

Accepted Answer

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

Sign in to comment.

More Answers (1)

Róbert Kakonyi
Róbert Kakonyi on 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.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!