https://blog.csdn.net/zhu2695/article/details/51982066
float 占位固定
很多控件共有的属性
name="thebtn"(用处:代表当前控件。)
text="文字"(用处:控件上显示的文字。textcolor可以设置它的颜色。disabledtextcolor禁用时的颜色。textpadding文字边距。)
tooltip="提示文字"(用处:鼠标放上去提示的文字。)
bgcolor="#FF00FF00"(用处:背景色。bkcolor2与bkcolor3=》背景渐变色。)
pos="10,10,100,30"(用处:定位。当float为true时,绝对定位。分别为left,top,right,bottom)
width="100" + height="30"(用处:尺寸。与pos相冲突,谁在后,以谁为准。)
minwidth="90" + minheight="20"(用处:最小宽高。)
maxwidth="120" + maxheight="50"(用处:最大宽高。)
align="left"(用处:对齐方式。)
padding="4,0,4,0"(用处:外边距。)
inset="4,0,4,0"(用处:内边距。)
bordersize="1"(用处:设置边框。)
bordercolor="#FF00FF00"(用处:普通边框颜色。)
focusbordercolor="#FF00FF00"(用处:获得焦点时边框颜色。)
borderround="4,4"(用处:边框四角的弧度。)
shortcut="P"(用处:设置快捷键ALT+P。)
font="1"(用处:头部定义的字体,按照序号排列,此处选择序号为1的字体。)
showhtml="true"(用处:可以在text中使用html来描述控件。)
endellipsis="true"(用处:若字体的长度超过控件的宽度,以...省略尾部。)
visible="false"(用处:隐藏控件。)
enabled="false"(用处:阻止控件响应消息。)
mouse="false"(用处:阻止控件响应鼠标消息。)
mousechild="false"(用处:阻止控件的子空间响应消息。)
vscrollbar="false"(用处:禁用垂直滚动条。)
hscrollbar="false"(用处:禁用水平滚动条。)
bkimage="img.png"(用处:设置背景图片。file=""从路径获取图片。res="",restype=""从资源获取图片。dest设置控件显示区域。source设置图片显示区域。corner设置拉伸区域。mask设置alpha值,使其可透明。fade设置透明度。xtiled,ytiled设置图片在x,y轴上平铺显示。)
sepwidth=""(用处:设置分隔符左右显示。)
sepheight=""(用处:设置分隔符上下显示。)
sepimm="true"(用处:拖动分隔符立即改变大小。)
一、按钮
用法示例:
[html] view plain copy
- <Button name="btnsdf" tooltip="这是按钮"
- float="true"
- pos="120,10,0,0"
- width="100"
- height="30"
- bkcolor="#FF00FF00"
- text="Hello World"
- shortcut="P"
- normalimage="file='SysBtn\xp_normal.png' source='1,1,59,24'"
- hotimage="file='SysBtn\xp_hot.png' source='1,1,59,24'"
- pushedimage="file='SysBtn\xp_pushed.png' source='1,1,59,24'"
- borderround="4,4" />
二、进度条
用法示例:
[html] view plain copy
- <Progress name="ProgressDemo1" text="Progress"
- float="true" pos="80,80,0,0"
- width="139" height="30" bkcolor="#FFFF0000"
- foreimage="SysBtn\xp_normal.png"
- min="0" max="100" value="50"
- hor="true" align="center" />
最小值min,最大值max,当前值value,进度条方向hor,foreimage为前景图片,bkcolor为背景色,也可设置背景图片bkimage,isstretchfore指定前景色是否缩放显示。
三、滑块控件
用法示例:
[html] view plain copy
- <Slider name="SliderDemo1" float="true"
- pos="30,77,0,0" width="139"
- height="18" thumbsize="12,20"
- bkimage="file='SysBtn/AdjustColorSliderH_foreground.bmp' mask='0xffff00ff'"
- thumbimage="file='SysBtn/SelectColor_SliderBar_Thumb.png' mask='0xffffffff'"/>
四、组合框控件comboBox
用法示例:
[html] view plain copy
- <Combo name="ComboDemo1" float="true" pos="30,264,0,0" width="139" height="30" normalimage="file='SysBtn/ComboBox/Combo_nor.bmp'" hotimage="file='SysBtn/ComboBox/Combo_over.bmp' " pushedimage="file='SysBtn/ComboBox/Combo_over.bmp' " >
- <ListLabelElement text="张三" selected="true" />
- <ListLabelElement text="李四" />
- </Combo>
五、列表控件listbox
用法示例:
[html] view plain copy
- <List name="ListDemo1" float="true" pos="30,150,0,0" width="139" height="100" bkcolor="#FFFFFFFF" header="hidden"
- itemtextcolor="#FF000000"
- itembkcolor="#FFE2DDDF"
- itemselectedtextcolor="#FF000000"
- itemselectedbkcolor="#FFC1E3FF"
- itemhottextcolor="#FF000000"
- itemhotbkcolor="#FFE9F5FF"
- itemdisabledtextcolor="#FFCCCCCC"
- itemdisabledbkcolor="#FFFFFFFF" >
- <ListLabelElement text="张三" selected="true" />
- <ListLabelElement text="李四" />
- </List>
六、表格控件listCtrl,也叫table控件,类似html中的table
用法示例:
[html] view plain copy
- <List name="ListDemo1" float="true" pos="30,150,0,0" width="139" height="100" bkcolor="#FFFFFFFF"
- itemtextcolor="#FF000000"
- itembkcolor="#FFE2DDDF"
- itemselectedtextcolor="#FF000000"
- itemselectedbkcolor="#FFC1E3FF"
- itemhottextcolor="#FF000000"
- itemhotbkcolor="#FFE9F5FF"
- itemdisabledtextcolor="#FFCCCCCC"
- itemdisabledbkcolor="#FFFFFFFF"
- vscrollbar="true"
- hscrollbar="true" >
- <ListHeader name="domain" bkimage="SysBtn\List/list_header_bg.png">
- <ListHeaderItem text="序号" width="40" height="23" minwidth="16" sepwidth="1" align="center" hotimage="SysBtn\List/list_header_hot.png" pushedimage="SysBtn\List/list_header_pushed.png" sepimage="SysBtn\List/list_header_sep.png" />
- <ListHeaderItem text="文件名称" width="84" height="23" minwidth="16" sepwidth="1" align="center" hotimage="SysBtn\List/list_header_hot.png" pushedimage="SysBtn\List/list_header_pushed.png" sepimage="SysBtn\List/list_header_sep.png" />
- </ListHeader>
- </List>
在初始化ui的时候添加数据
[cpp] view plain copy
- virtual void InitWindow() {
- CDuiString str;
- CListUI* pList = static_cast<CListUI*>(m_PaintManager.FindControl(_T("ListDemo1")));
- // 添加List列表内容,必须先Add(pListElement),再SetText
- for (int i = 0; i < 10; i++)
- {
- CListTextElementUI* pListElement = new CListTextElementUI;
- pListElement->SetTag(i);
- pList->Add(pListElement);
- str.Format(_T("%d"), i);
- pListElement->SetText(0, str);
- pListElement->SetText(1, _T("haha"));
- }
- }
七、抽屉控件,tab控件
用法示例
[html] view plain copy
- <Option name="OptionDemo1" text="Option1" float="true" pos="207,28,0,0" width="60" height="30" bkcolor="#FFC5D4F2" selectedtextcolor="#FF0000FF" selectedbkcolor="#FFC5D4F2" group="tabDemo" selected="true" />
- <Option name="OptionDemo2" text="Option2" float="true" pos="284,28,0,0" width="60" height="30" bkcolor="#FFFFDC78" group="tabDemo" />
- <Option name="OptionDemo3" text="Option3" float="true" pos="361,28,0,0" width="60" height="30" bkcolor="#FFBECEA1" group="tabDemo" />
- <TabLayout name="tabTest" float="true" pos="202,75,0,0" width="255" height="169" bkcolor="#FF757676">
- <VerticalLayout pos="0,0,200,150" bkcolor="#FF00FFFF"></VerticalLayout>
- <VerticalLayout pos="0,0,200,150" bkcolor="#FF00FF00"></VerticalLayout>
- <VerticalLayout pos="0,0,200,150" bkcolor="#FFFF00FF"></VerticalLayout>
- </TabLayout>
代码部分
[cpp] view plain copy
- else if (msg.sType == _T("selectchanged"))
- {
- CDuiString strName = msg.pSender->GetName();
- CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_PaintManager.FindControl(_T("tabTest")));
- if (strName == _T("OptionDemo1"))
- pControl->SelectItem(0);
- else if (strName == _T("OptionDemo2"))
- pControl->SelectItem(1);
- else if (strName == _T("OptionDemo3"))
- pControl->SelectItem(2);
- }