function [GUIopen, hGUI] = mpc_getGUIstatus(blkh)
% GETGUISTATUS Get status and handle to a GUI task opened by an MPC block mask

%   Authors: A. Bemporad
%   Copyright 1986-2007 The MathWorks, Inc.

% Finds the (current) MPC task node in GUI for a given block.
f = mpcgetblockdialog(blkh);
if isempty(f)
    GUIopen = false;
    hGUI=[];
else
    hGUI = getappdata(f(1),'hGUI');
    GUIopen = ~isempty(hGUI) && ishandle(hGUI);
end
