How can I determine if a help dialog box is open, and then close it if it is open

6 views (last 30 days)
This dialog box is opened by a function in a class object. If a class object function hangs up, the dialog box is left open. The dialog box is created by the following obj.info = op_status(obj.info,'Running');
op_status function is: function rc = op_status(fh,str) fh =helpdlg(str, 'Tester Status'); set(fh,'Position',[10 260 160 60],'MenuBar','none'); rc = fh; end
I can close the dialog box by issuing the simple command close(obj.info).
But, if the box is already closed, I get this error message:
??? Error using ==> close at 93
Invalid figure handle.
I want to include this within a script or function to reset figures and listeners, etc. when something hangs up.
I tried findobj to detect the help dialog box, but it does not seem to detect it.

Accepted Answer

Paulo Silva
Paulo Silva on 18 Mar 2011
try
close(obj.info)
catch
end
  1 Comment
Paulo Silva
Paulo Silva on 21 Mar 2011
Elaine you accepted my answer but the other answers are better, please select other answer or I will delete this one, thanks

Sign in to comment.

More Answers (2)

Matt Fig
Matt Fig on 18 Mar 2011
For future reference, FINDOBJ won't return the handle to objects which have handlevisibility set to off. Use FINDALL instead. In particular,
helpdlg('Help string','Help Dialog')
findall(0,'tag','Msgbox_Help Dialog') % Notice how Tag was made.

Jan
Jan on 19 Mar 2011
if ishandle(obj.info)
delete(obj.info)
end

Categories

Find more on Code Execution in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!