print figure shows hidden objects

조회 수: 2 (최근 30일)
Eric Keller
Eric Keller 2011년 4월 4일
I have a gui that I created without using guide. There are various configurations, and I switch between them by hiding gui elements. This works great up until the user tries to do a screen print, where this piece of code from "prepare.m" is invoked by the "print" function:
%Need to see everything when printing hiddenH = get( 0, 'showhiddenhandles' ); set( 0, 'showhiddenhandles', 'on' )
Not clear why we need to see everything when printing, makes no sense to me. If I want to show the hidden handles, I'd make them visible. Any suggestions?

채택된 답변

Eric Keller
Eric Keller 2011년 5월 6일

추가 답변 (3개)

Jan
Jan 2011년 4월 4일
"set(0, 'showhiddenhandles', 'on')" does not make anything visible. It allows to include the handles a.g. when getting the children of an HG-object. See also:
docsearch ShowHiddenHandles
docsearch HandleVisibility
What problems do occur when printing?

Eric Keller
Eric Keller 2011년 5월 5일
that just means I didn't find the right line of code. This program shows the behavior I have seeing. When you open the jpeg, you get a surprise.
function bugshowD
h_main = figure('name', 'bugshowD', ...
'Visible', 'on', ...
'OuterPosition', [200 200 360 360]);
hprintbutton = uicontrol(h_main, ...
'Style', 'pushbutton', ...
'Position', [10 10 70 70], ...
'String', 'Print',...
'Callback', @printsave);
hpanel = uipanel('Parent', h_main, ...
'Position',[ 110 110 240 240], ...
'Title', 'Panel',...
'visible','off');
hhiddenbutton = uicontrol(hpanel, ...
'Style', 'pushbutton', ...
'Position', [5 5 70 70], ...
'String', 'neverseen',...
'Callback', @nothing,...
'visible','on');
function printsave(windowname,~)
[ffile, fpath, findex] = uiputfile( ...
{'*.jpg', 'jpeg file (*.jpg)';
'*.eps', 'encapsulated postscript file (*.eps)'},...
'save screen capture', 'screenprint');
print(['-f' num2str(h_main)], fullfile(fpath, ffile), '-djpeg80', '-r300')
end
end

Eric Keller
Eric Keller 2011년 5월 5일
I'd just like to add that when I wrote this little program, and omitted the uipanel, that it didn't show the hidden button. This makes me think that it's just a bug with hidden uipanels. This behavior also shows up if you use printdlg

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by