function dp = findDialogPresenter(hfig)
% Return handle to a DialogPresenter object based on a figure handle, or
% a handle to a parent uipanel or other graphical container.
%
% If no DialogPresenter is present, returns empty.

%   Copyright 2010 The MathWorks, Inc.

if nargin<1
    hfig = gcf;
end
hParent = findobj(hfig,'type','uipanel','tag','DialogPresenter_hParent');
if isempty(hParent)
    dp = [];
else
    dp = get(hParent,'UserData');
end

