Why do the static textboxes in my GUI print in gray color unlike the GUI background?

1 vue (au cours des 30 derniers jours)
I have a GUI which has several static textbox objects in it. When I print my GUI, the textboxes are printed in gray color unlike the GUI background, which is white. I would like the textboxes to print in the same color as the GUI background. I also do not want to set the color of the textbox to white in GUIDE.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 27 Juin 2009
The textboxes in a GUI not printing in the same color as the background is an expected behavior.
A workaround for printing the textboxes in white color is to set the background color of the textboxes to white. The color of the textboxes can then be reverted to the original color after the printing is completed. The following code can be added to the Shortcut to accomplish this task.
% Show Hidden Handles to identify the GUI figure
set(0,'showHiddenHandles','on')
% Identify the GUI figure
figureHandle = findobj(0,'Type','Figure');
% Extract the GUI's children
childrenHandles = get(figureHandle,'Children');
% Identify the textbox object handles
textBoxHandles = findobj(childrenHandles,'Style','text');
% Store the original background color of the textbox
originalBGColor = get(textBoxHandles(1),'BackgroundColor');
% Set the background color of textboxes to white
set(textBoxHandles,'BackgroundColor','w')
% Print the GUI figure
print(figureHandle)
% Revert the background color of textboxes to the original color
set(textBoxHandles,'BackgroundColor',originalBGColor)
Note if using PRINTDLG (or other substitutions for PRINT) that you may need to allow printing to finish before the last line
set(textBoxHandles,'BackgroundColor',originalBGColor)
can be executed. Simply insert a PAUSE command or manually remove this last line and execute it separately.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by