function setenableprop(h,enableState,uistyle)
%SETENABLEPROP Sets the enable property of uicontrols while maintaining the 
%              correct background color.
% Inputs:
%   h           - handle to uicontrol to enable/disable.
%   enableState - enable property value: 'on' or 'off'.
%   uistyle     - the uicontrol style, e.g., 'edit', 'popupmenu'.
%
% Outputs:
%   none

%   Author(s): P. Pacheco
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.2 $  $Date: 2000/06/13 21:23:37 $ 

% Background colors.
enabledColor = 'White';
disabledColor = [0.8 0.8 0.8];

if strcmp(enableState,'on'),  bgColor = enabledColor;
else                          bgColor = disabledColor;
end

switch uistyle
case {'edit','popupmenu'}
    set(h,'Enable',enableState,'Background',bgColor);
    
otherwise  % In case someone uses this function for other uis.
    set(h,'Enable',enableState);
end
drawnow;

% [EOF] setenableprop.m
