新浪博客

GUI中ispc && isequal(get(hObject,'BackgroundColor')等代码含义

2017-02-09 21:44阅读:
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
>>help ispc
ISPC True for the PC (Windows) version of MATLAB.
ISPC returns 1 for PC (Windows) versions of MATLAB and 0 otherwise.
See also computer, isunix, ismac.
Reference page in Help browser
doc ispc
简而言之:就是matlab是不是Windows版本,很明显matlab装在Windows操作系统上当然是PC版,
所以PC版ispc为1;
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
isequal是判断相等函数,括号里判断的是当前对象的背景色和ui界面的默认的背景色(一般为灰色)
set(hObject,'BackgroundColor','white');
设置当前对象背景色为白色

函数的功能综上所述:
判断当前matlab是不是windows版本,同时当前对象的背景颜色与根对象默认背景颜色(一般为灰色)是不是相同,如果是,那么当前对象的背景色改为白色。
所以编辑框或列表框
等是白色的
本语句一般出现在XX_CreateFcn(hObject, eventdata, handles)函数中;

我的更多文章

下载客户端阅读体验更佳

APP专享