print figure shows hidden objects

9 次查看(过去 30 天)
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 中查找有关 App Building 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by