www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/mbcfindfigure.m

    function hFig = mbcfindfigure(obj)
%MBCFINDFIGURE Find the parent figure of an object
%
%  HFIG = MBCFINDFIGURE(OBJ) returns a handle to the figure that OBJ is in.
%  This algorithm works by recursively getting the parent until a figure is
%  reached.  If OBJ is not in a figure or OBJ is empty, HFIG is returned as
%  an empty.

%  Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc.


hFig = obj;
while mbcgui.util.isComponentHandle(hFig) && ~isgraphics(hFig,'figure')
    if isprop(hFig, 'Parent')
        hFig = get(hFig, 'Parent');
    else
        hFig = [];
        break
    end
end