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

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.

 채택된 답변

try
close(obj.info)
catch
end

댓글 수: 1

Elaine you accepted my answer but the other answers are better, please select other answer or I will delete this one, thanks

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

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.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2011년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by