SOUI总结之控件说明
控件说明
文件包含(include)说明
使用处添加 <include src="layout:dlg_OTP"/>
写法:
<include>
<window size="-2,-2" layout="hbox"/>
</include>
SOUI说明
<SOUI trCtx="dlg_main" title="SOUI-DEMO" bigIcon="ICON_LOGO:32" smallIcon="ICON_LOGO:16" width="666"
height="400" wndType="appMain" margin="10,10,10,10" resizable="1" translucent="1" sendWheel2Hover="1"
alpha="255">
sendWheel2Hover属性是滚动条适用于当前窗口,当窗口存在滚动条时比较重要的一个属性。
注意:margin="5,5,5,5"时会出现只能上下调整大小,不能左右调整大小的情况;需要改为margin="10,10,10,10"才行,目前原因未知。
标题栏(caption)说明
<caption pos="0,0,-0,30" class="cls_txt_red" font="adding:8" focusable="1" drawfocusrect="0">
<icon pos="10,8" src="ICON_LOGO:16"/>
<text pos="[5,4" name="txt_title"/>
<imgbtn id="1" skin="_skin.sys.btn.close" pos="-45,0" tip="close" animate="1"/>
<imgbtn id="2" skin="_skin.sys.btn.maximize" pos="-83,0" animate="1" />
<imgbtn id="3" skin="_skin.sys.btn.restore" pos="-83,0" show="0" animate="1" />
<imgbtn id="5" skin="_skin.sys.btn.minimize" pos="-121,0" animate="1" />
<imgbtn name="btn_menu" skin="skin_btn_menu" pos="-151,2" animate="1" />
<imgbtn name="btn_skin" skin="skin_btn_skin" pos="-181,2" animate="1"/>
</caption>
窗口(window)说明
类名:SWindow
控件名:window
基类:SObject、SMsgHandleState、TObjRefImpl2<IObjRef,SWindow>
说明:大多数界面控件本质上都是窗口,该类是大部分界面控件的基类;绝大部分控件都拥有该类的属性和方法。
属性名 |
类型 |
说明 |
id |
数字 |
窗口 ID |
name |
字符串 |
窗口名称 |
skin |
字符串 |
窗口 |
ncskin |
字符串 |
窗口绘制非客户区边框时引用的 ISkinObj 对象名称 |
class |
字符串 |
窗口的属性集合(WndStyle)的名称 |
data |
用户数据 |
|
enable |
0|1 |
控件是否可用(0--不可用 1--可用) |
visible |
0|1 |
控件是否可见(0--隐藏 1--可见) |
show |
0|1 |
控件是否可见(0--隐藏 1--可见) |
pos |
负数,|,[,],%,@ |
控件位置 |
cache |
0|1 |
绘制缓存(0--无绘制缓存(默认) 1--有绘制缓存) |
display |
0|1 |
显示(0--隐藏不占位 1--隐藏占位(默认)) |
tip |
字符串 |
提示框 |
msgTransparent |
0|1 |
消息穿透(0--接收鼠标键盘消息(默认) 1--不接收) |
sep |
正整数 |
窗口默认间距 |
maxWidth |
数字 |
窗口最大宽度 |
clipClient |
0|1 |
是否在绘制窗口时限制内容只绘制在客户区(0--不剪裁(默认) 1--剪裁) |
focusable |
0|1 |
窗口是否接受焦点(0--不接受 1--接受(默认)) |
alpha |
[0-255] |
绘制窗口的透明度 |
注意:
<icon src="ICON_LOGO:32" msgTransparent="1"/>
如果msgTransparent的值为0,当icon的父窗口是caption时,鼠标点击不能拖动窗口;
如果msgTransparent的值为1,当icon的父窗口是caption时,鼠标点击就能拖动窗口;
SwndStyle 类
类名:SwndStyle
控件名:style
基类:SObject
说明:大多数界面控件本质上都是窗口,该类是大部分界面控件的基类;绝大部分控件都拥有该类的属性和方法。
属性名 |
类型 |
说明 |
textMode |
数字 |
文字绘制的格式 |
align |
字符串 |
水平显示方式(left,center,right) |
valign |
字符串 |
垂直显示方式(top,middle,bottom) |
colorBkgnd |
color |
背景颜色 |
colorBorder |
color |
边框颜色 |
font |
字符串 |
默认字体 |
fontHover |
字符串 |
悬留时字体 |
fontPush |
字符串 |
按下时字体 |
fontDisable |
字符串 |
失效时字体 |
colorText |
color |
默认字体颜色 |
colorTextHover |
color |
悬停时字体颜色 |
colorTextPush |
color |
按下时字体颜色 |
colorTextDisable |
color |
失效时字体颜色 |
margin-x |
数字 |
非客户区 left 及 right 宽度 |
margin-y |
数字 |
非客户区 top 及 bottom 宽度 |
margin |
数字 |
非客户区宽度 |
cursor |
字符串 |
光标(指定光标资源名称) |
dotted |
0|1 |
在文件绘制长度超出客户区时是否使用"…"(0--不使用(默认) 1--使用) |
注意:窗口还有一个属性叫readOnly="1",只读;但是由于各种原因没有在代码及文档中找到这个属性。
SHostWndAttr 类
类名:SHostWndAttr
控件名:hostwndattr
基类:SObject
说明:大多数界面控件本质上都是窗口,该类是大部分界面控件的基类;绝大部分控件都拥有该类的属性和方法。
属性名 |
类型 |
说明 |
name |
名称 |
|
title |
标题 |
|
size |
窗口大小 |
|
width |
宽度 |
|
height |
高度 |
|
margin |
位置 |
|
minsize |
最小大小 |
|
wndStyle |
样式 |
|
wndStyleEx |
扩展样式 |
|
resizable |
0|1 |
host 可变大小(0--不可变 1--可变大小) |
translucent |
host 半透明 |
|
appWnd |
host 在任务栏显示图标 |
|
toolWindow |
0|1 |
host 的扩展样式是否为 WS_EX_TOOLWINDOW(0--无 1--有) |
smallIcon |
iconname:size |
小图标 |
bigIcon |
iconname:size |
大图标 |
<window pos="1,1,-1,-1" id="9527" skin="demoskinbk" cache="1" colorBkgnd="#169ada"/>
show和dispaly可以配合达到占位与不占位的效果。
colorBkgnd="#ffffff44" 颜色表示为前6位为rgb,后两位为颜色透明度。
scrolltext写法
<scrolltext pos="0,0,-0,-0" font="style:StrokeAndFill,blurStyle:solid,blurRadius:3,adding:5 " msgTransparent="1">
苦涩的沙吹痛脸庞的感觉 像父亲的责骂 母亲的哭泣 永远难忘记 年少的我 喜欢一个人在海边 卷起裤管光着脚丫踩在沙滩上
</scrolltext>
<scrolltext show="1" pos="{0,[10,@200,@30" rollType="1" colorText="#ff0000" speed="10">Pay attention! apng would be played only if imgdecoder-png is used here!</scrolltext>
线条控件(hr)说明
类名:SLine
控件名:hr
基类:SWindow
说明:图片控件类,此窗口支持动画效果。
属性名 |
类型 |
说明 |
size |
数字 |
大小 |
mode |
字符串 |
方向(vertical,horizontal,tilt) |
lineStyle |
字符串 |
样式(solid,dash,dot,dashdot,dashdotdot) |
<hr pos="0,0,-0,1" colorLine="#666666" />
<hr pos="10,{0,@2,-10" lineStyle="solid" mode="vertical" colorLine="#0000ff" size="2"/>
热键(hotkey)说明
<hotkey name="ctrl_hk1" width="200" height="25" class="cls_edit"/>
需要继承SOUI::IMessageFilter
虚函数BOOL PreTranslateMessage(MSG* pMsg);
BOOL CMainDlg::PreTranslateMessage(MSG* pMsg)
{
if ( pMsg->message == WM_HOTKEY )
{
UINT nIndex = LOWORD(pMsg->wParam);
}
return FALSE;
}
把当前类添加到消息管理
m_pHostWnd->GetContainer()->GetMsgLoop()->AddMessageFilter(this);
animateimg写法
<animateimg pos="|0,|0" offset="-0.5,-0.5" skin="skin_busy" name="ani_test" tip="animateimg is used here" msgTransparent="0" />
滚动条控件(scrollbar)说明
类名:SScrollBar
控件名:scrollbar
基类:SWindow
说明:滚动条控件
属性名 |
类型 |
说明 |
skin |
字符串 |
皮肤 |
arrowSize |
数字 |
箭头大小 |
min |
数字 |
最小值 |
max |
数字 |
最大值 |
value |
数字 |
当前值 |
page |
数字 |
翻页大小 |
Vertical |
0|1 |
是否垂直(0-- 否 1--是) |
<scrollbar name="sb_test1" pos="[10,10,@200,@16" min="0" max="100" value="10" page="10" vertical="0"/>
滑块工具条(sliderbar)
类名:SSliderBar
控件名:sliderbar
基类:SProgress
说明:滑块工具条控件
属性名 |
类型 |
说明 |
thumbSkin |
字符串 |
拖动按钮的皮肤 |
thumbInRail |
0|1 |
滑块包含在轨道中 |
<sliderbar name="slider_test" thumbInRail="0" pos="100,[10" alpha="200" width="200" value="20" min="0" max="100"/>
<sliderbar name="slider_test2" thumbInRail="1" pos="100,[10" alpha="200" width="200" value="20" min="0" max="100"/>
<sliderbar name="slider_test3" thumbInRail="0" vertical="1" pos="10,10" alpha="200" height="200" value="20" min="0" max="100"/>
<sliderbar name="slider_test4" thumbInRail="1" vertical="1" pos="[10,10" alpha="200" height="200" value="20" min="0" max="100"/>
滑动条滑动事件EventSliderPos::EventID。
EVENT_NAME_HANDLER(L"slider_sound_volume", EventSliderPos::EventID, OnSliderPosVolume)
void CMainDlg::OnSliderPos(EventArgs *pEvt)
{
EventSliderPos* e = sobj_cast<EventSliderPos>(pEvt);
if (e)
{
int nPos = e->nPos;
OutputDebugString(SStringW().Format(L"滑块值:%d\n", nPos));
}
}
propgrid写法
<propgrid pos="10,50,-100,-10" nameWidth="180" orderType="group" switchSkin="skin_propswitch" colorBkgnd="#ffffff" itemHeight="30">
<cmdbtnstyle skin="_skin.sys.btn.normal">...</cmdbtnstyle>
<groups>
<propgroup name="group1" description="desc of group1">
<proptext name="text1.1" value="value 1.1">
<proptext name="text1.1.3" value="value 1.1.3"/>
<proptext name="text1.1.1" value="value 1.1.1"/>
<proptext name="text1.1.2" value="value 1.1.2">
<proptext name="text1.1.2" value="value 1.1.2"/>
</proptext>
</proptext>
<proptext name="text1.2" value="value 1.2"></proptext>
</propgroup>
<propgroup name="group2" description="desc of group2">
<propoption name="option2.1" value="1" options="true|false|empty"/>
<propsize name="size2.1" value="200,300" childrenNames="宽|高"/>
<proptext name="text2.2" value="value 2.2"></proptext>
<propcolor name="color2.1" value="#00ff00" format="#%02x%02x%02x%02x"/>
<proptext name="text2.1" value="value 2.1"/>
<proptext name="text2.3" value="value 2.3"/>
<proptext name="text2.4" value="value 2.4"/>
<proptext name="text2.5" value="value 2.5"/>
<proptext name="text2.6" value="value 2.6"/>
<proptext name="text2.7" value="value 2.7"/>
<proptext name="text2.8" value="value 2.8"/>
</propgroup>
</groups>
</propgrid>
gifplayer控件说明
基类:SSkinAni
类名:SSkinGif
控件名:gif
属性名 |
类型 |
说明 |
src |
字符串 |
XML文件中指定的图片资源名,(type:name) |
<gif name="skin_file_gif" src="file:image\test.gif"/>
注意:需要进行注册
theApp->RegisterSkinClass<SSkinGif>();//注册SkinGif
基类:SWindow,ITimelineHandler
类名:SGifPlayer
控件名:gifplayer
属性名 |
类型 |
说明 |
skin |
字符串 |
为控件提供一个skin属性,用来接收SSkinObj对象的name |
<gifplayer pos="10,10" skin="gif_horse" name="giftest" cursor="ANI_ARROW" show="1"/>
注意:需要进行注册
theApp->RegisterWindowClass<SGifPlayer>();
dateTimePicker写法
<window size="-2,-1" layout="hbox" padding="5,5,5,5">
<dateTimePicker size="240,30" name="timepicker" padding="4,0,4,0" dropWidth="300" timeEnable="1" >
<calstyle ncSkin="_skin.sys.border" daySkin="_skin.sys.btn.normal" margin="1"/>
</dateTimePicker>
</window>
<calendar size="-2,0" weight="1" name="mp_test" daySkin="_skin.sys.btn.normal" footerHeight="30"/>
分割窗口控件说明
基类:SWindow
类名:SSplitPane
控件名:pane
属性名 |
类型 |
说明 |
idealSize |
数字 |
期望大小 |
minSize |
数字 |
最小大小 |
priority |
数字 |
优先级(值越小优先级越高) |
基类:SWindow
类名:SSplitWnd
控件名:splitwnd
说明:分割窗口控件
属性名 |
类型 |
说明 |
sepSize |
数字 |
分隔条宽度/高度 |
adjustable |
0|1 |
是否可以拖动(0-不可拖动,1-可以拖动) |
colmode |
0|1 |
分栏模式(0-横向分栏,1-纵向分栏) |
skinSep |
字符串 |
分隔条绘制皮肤(皮肤 name) |
<splitrow name="split_row" pos="10,0,-10,-10" sepSize="6">
<pane idealSize="250" minSize="30" priority="2" colorBkgnd="#880000" clipClient="1">
<text pos="|-50,|-20" colorText="#ffffff">pane1 priority=2</text>
</pane>
<pane idealSize="400" minSize="30" priority="1">
<splitcol name="split_col" pos="0,0,-0,-0" sepSize="6">
<pane idealSize="200" minSize="30" priority="0" colorBkgnd="#000088" clipClient="1">
<text pos="|-50,|-20" colorText="#ffffff">pane2.1 priority=0</text>
</pane>
<pane idealSize="400" minSize="30" priority="1" colorBkgnd="#008800" clipClient="1">
<text pos="|-50,|-20" colorText="#ff0000">pane2.2 priority=1</text>
</pane>
</splitcol>
</pane>
</splitrow>
实现显示与隐藏
SSplitWnd_Row* pSplit = FindChildByName2<SSplitWnd_Row>(L"splitrowMain");
if (pSplit)
{
pSplit->HidePane(1);
}
SSplitWnd_Row* pSplit = FindChildByName2<SSplitWnd_Row>(L"splitrowMain");
if (pSplit)
{
pSplit->ShowPane(1);
}
窗口滚动(scrollview)控件说明
<scrollview name=”scrvIO” size="-2,-2" viewSize="-1,-1" layout="vbox" scrollSpeed="50" sbWid="5" sbSkin="skin_vscrollbar">
<button size="800,30" name="btn_test" tip="click the button to see how to writing the response function">btn</button>
<button size="800,30" name="btn_test" tip="click the button to see how to writing the response function">btn</button>
<button size="800,30" name="btn_test" tip="click the button to see how to writing the response function">btn</button>
<button size="800,30" name="btn_test" tip="click the button to see how to writing the response function">btn</button>
<button size="800,30" name="btn_test" tip="click the button to see how to writing the response function">btn</button>
</scrollview>
问题1:viewSize属性是什么?
sbWid属性是垂直滚动条的宽度。
sbSkin是垂直滚动条皮肤。
scrollSpeed滚动条速度。
注意:需要注册纵向滚动条皮肤
m_pTheApp->RegisterSkinClass<SSkinVScrollbar>();//注册纵向滚动条皮肤
图标(icon)控件说明
属性名 |
类型 |
说明 |
src |
字符串 |
指定 icon 图标(iconname:size) |
<icon pos="10,8" src="ICON_LOGO:16"/>
<icon pos="[10,{0" src="LOGO:64"/>
ICON_LOGO:16表示16*16的图标。
ICON_LOGO:32表示32*32的图标。
图片(img)控件说明
基类:SWindow
类名:SImageWnd
<img name="img_icon" skin="skin_icon6" pos="10,8,@64,@64"/>
动态设置图片
void SetImgState(SStringT strImg,int nState)
{
SImageWnd* img = m_pPageRoot->FindChildByName2<SImageWnd>(strImg);
if (img)
{
ISkinObj *skin;
if (nState == 1)
{
skin = GETSKIN(L"skin_Erase",1);
}
else if(nState == 0)
{
skin = GETSKIN(L"skin_Apply",1);
}
else
{
skin = GETSKIN(L"skin_default",1);
}
img->SetSkin(skin);
}
}
静态文本(text)控件说明
基类:SWindow
类名:SStatic
属性名 |
类型 |
说明 |
multiLines |
0|1 |
多行显示(0--否 1--是) |
interHeight |
数字 |
多行显示时行间距 |
说明:静态文本控件可支持多行,有多行属性时,\n 可以强制换行。
text写法
属性名 |
类型 |
说明 |
multiLines |
0|1 |
多行显示(0--否 1--是) |
interHeight |
数字 |
多行显示时行间距 |
<text pos="[5,4" name="txt_title"/>
<text pos="10,[0" multiLines="1" maxWidth="500" colorText="@color/red">text in odd item</text>
字体大小size="14"最适合。
<text pos="|0,|0" offset="-0.5,-0.5" font="face:黑体,bold:2,adding:20" colorText="#ff000066">多点桌面 dock演示 </text>
font="italic:1"
font="adding:-2"
上面text标签演示font属性的具体写法。
<text size="40,30" align="left">NAME:</text>
可以使用align属性对齐。
超链(link)接控件
<class name="cls_btn_weblink" cursor="hand" colorText="#ffffff" colorTextHover="#ffffff" fontHover="underline:1,italic:1" />
<link extend_left="15" maxWidth="100" class="cls_btn_weblink" dotted="1" href="www.ui520.cn">串口未打开</link>
属性名 |
类型 |
说明 |
href |
字符串 |
超链接 |
按钮(button,imgbtn)控件说明
类名:SButton、SImageButton
控件名:button、imgbtn
基类:SWindow、IAcceleratorTarget、ITimelineHandler
说明:显示按钮,是从 SWindow 派生的,所以基类控件具有的属性和函数也可以使用。按钮的背景图片是由 4 张切图拼接成的大图片,分别是普通状态、鼠标移动状态、鼠标按下状态、禁用状态的图片,背景图片设置可以通过 skin 属性设置。按钮控件有两种控件名,button 和 imgbtn,唯一的差别是 imgbtn 默认会无法获取焦点,即用 Tab 键无法选中 imgbtn 按钮。
属性名 |
类型 |
说明 |
accel |
加速键格式 |
键盘加速键 |
animate |
0|1 |
动画效果(0--关闭 1--启用) |
<button pos="10,5,@150,@25" name="btn_test" tip="click the button ">btn</button>
<imgbtn id="1" skin="_skin.sys.btn.close" pos="-45,0" tip="close" animate="1"/>
<imgbtn animate="1" pos="|-35,|-14" font="adding:-3" align="center" skin="skin_install" name="btn_uninstall">卸载</imgbtn>
<imgbtn id="1" skin="_skin.sys.btn.close" pos="-45,0" tip="close" animate="1"/>
<imgbtn id="2" skin="_skin.sys.btn.maximize" pos="-83,0" animate="1" />
<imgbtn id="3" skin="_skin.sys.btn.restore" pos="-83,0" show="0" animate="1" />
<imgbtn id="5" skin="_skin.sys.btn.minimize" pos="-121,0" animate="1" />
<imgbtn name="btn_menu" skin="skin_btn_menu" pos="-151,2" animate="1" />
<imgbtn name="btn_skin" skin="skin_btn_skin" pos="-181,2" animate="1"/>
按钮的大小size="70,28"看上去是最舒服的尺寸。
单选框(radio)控件说明
基类:SWindow
类名:SRadioBox
属性名 |
类型 |
说明 |
skin |
字符串 |
默认皮肤 |
focusSkin |
字符串 |
|
checked |
0|1 |
是否选中(0--不选中 1--选中) |
iconAlign |
字符串 |
图标水平显示方式left|center|right |
iconValign |
字符串 |
图标垂直显示方式top|middle|bottom |
<radio pos="10,[10" id="10003" name="radio2_4" drawFocusRect="0" checked="1" skin="skin_webbtn_forward"></radio>
<radio size="-1,-2" weight="1" focusable="0" skin="skin_group" iconAlign="center" iconValign="bottom" text="群组" align="center" valign="bottom" />
复选框(check)控件说明
基类:SWindow
类名:SCheckBox
属性名 |
类型 |
说明 |
skin |
字符串 |
默认皮肤 |
focusSkin |
字符串 |
焦点皮肤 |
checked |
0|1 |
是否选中(0--不选中 1--选中) |
<check pos="250,90" offset="-1,0">check right top</check>
<check pos="250,110" offset="-1,0" font="adding:-5">check right top1235</check>
数字按钮(spinButton)控件说明
基类:SWindow
类名:SSpinButtonCtrl
属性名 |
类型 |
说明 |
max |
数字 |
显示的最大值 |
min |
数字 |
显示的最小值 |
value |
数字 |
显示的值 |
step |
数字 |
点击上下,数字跳动的大小 |
circle |
0|1 |
循环,即最大值再点击上就是最小值 |
buddy |
字符串 |
绑定的编辑框控件名 |
upskin |
字符串 |
上键皮肤 |
downSkin |
字符串 |
下键皮肤 |
<window pos="10,[5,@100,@30" class="cls_edit" trackMouseEvent="1">
<edit pos="0,0,-16,-0" name="edit_spin" notifyChange="1" margin-x="0" margin-y="0"/>
<spinButton pos="[0,0,-0,-0" max="100" min="1" value="31" buddy="edit_spin"/>
</window>
其中cls_edit
<class name="cls_edit" ncSkin="_skin.sys.border" margin-x="2" margin-y="2" transParent="1"/>
当值发生改变时会触发EventSpinValue2String::EventID事件
例:EVENT_ID_RANGE_HANDLER(500000,599999, EventSpinValue2String::EventID, OnSpinBtnValueChanged)
void CUIEventHandler::OnSpinBtnValueChanged(EventArgs *pEvt)
{
EventSpinValue2String *pEvtSpin = sobj_cast<EventSpinValue2String>(pEvt);
}
富文本(richedit)控件说明
基类:SPanel〖SWindow〗
类名:SRichEdit
属性名 |
类型 |
richedit 的 style |
style |
数字 |
多行显示(0--否 1--是) |
maxBuf |
最大容纳字符 |
|
transparent |
0|1 |
指示 edit 控件是否背景透明,默认透明 (0--不透明 1--透明) |
rich |
0|1 |
是否为富文本控件,默认 richedit (0--普通 edit 1--richedit) |
vertical |
0|1 |
是否允许垂直(0--禁止 1--允许) |
wordWrap |
0|1 |
英文单词可以折断(0--禁止 1--允许) |
allowBeep |
0|1 |
错误时有提示音(0--禁止 1--允许) |
autoWordSel |
自动选择单词 |
|
vcenter |
0|1 |
单行垂直居中(0--否 1--是) |
inset |
数字 |
edit 的边缘大小(inset="5,5,5,5") |
colorText |
color |
文本颜色 |
<richedit name="edit_xml" pos="0,0,|0,-0" multilines="1" autoVscroll="1" wordwrap="1" margin-x="2" margin-y="2" cueText="问候语" vscrollBar="1">你好,邹耀明</richedit>
注意:富文本框默认最大显示字符为65535。
编辑框(edit)控件说明
基类:SRichEdit
类名:SEdit
1.<edit name="edit_drop_top" pos="10,10,-10,]-10" cueText="draging a file to me to see what will happen"/>
2.<edit pos="0,0,-30,-0" font="adding:10" margin="0" cueText="cue text" cueColor="rgb(255,0,0)" password="1">scroll edit</edit>
3.<edit ncSkin="_skin.sys.border" transparent ="1" margin-x="2" margin-y="2"/>,是edit在init当中的写法。
注意:编辑框默认最大显示字符为65535。编辑框的高度28看上去是最舒服的尺寸。
编辑框文本更改事件:
1.在初始化对话框OnInitDialog中
pWnd = FindChildByName(L"editFile");
if (pWnd)
{
pWnd->SSendMessage(EM_SETEVENTMASK, 0, ENM_CHANGE);
}
2.在事件映射表中
EVENT_NAME_HANDLER(L"edit_search", EVT_RE_NOTIFY, OnEditSearch)
3.声明并实现
void OnEditSearch(EventArgs* pEvt);
void CGPIOInit::OnEditSearch(EventArgs* pEvt)
{
EventRENotify* pRE = (EventRENotify*)pEvt;
if (pRE->iNotify == EN_CHANGE)
{
}
return true;
}
编辑框获取焦点与失去焦点事件
EVENT_ID_RANGE_HANDLER(400000,499999,EventSetFocus::EventID,OnEditSetFocus)
EVENT_ID_RANGE_HANDLER(400000,499999,EventKillFocus::EventID,OnEditKillFocus)
扩展编辑(chatedit)框控件说明
<chatedit name="re_gifhost" pos="5,[5,-5,-5" bkgndBlend="1" class="cls_edit" enableDragdrop="1" multiLines="1" vscrollBar="1" sbSkin="skin_vscrollbar" wordWrap="1" autoVscroll="1" hscrollBar="0" wantReturn="1" maxBuf="6400000" rtf="rtf:rtf_test"/>
注意:chatedit控件在controls.extend文件夹中,属于扩展控件需要注册窗口,如下:
TheApp->RegisterWindowClass<SChatEdit>();
在这之前需要用到库文件smiley.lib,这个库文件有两个版本Debug版本smileyd.lib,与Release版本smiley.lib,分别用在调试模式与发行模式中,不要弄混了。
用法1:一段文字为一种样式
SChatEdit * edit = m_pPageRoot->FindChildByName2<SChatEdit>(strName);
if (edit)
{
SStringT strMsg;
strMsg.Format(_T("<color value=\"%s\"><font value=\"微软雅黑\"><size value=\"14\">%s</size></font></color>"),strColor,strInfo);
edit->AppendFormatText(strMsg);
}
用法2:一个文字为一种样式
SStringT strText;
SStringT strMsg;
strMsg.Format(_T("<color value=\"#ff0000\"><font value=\"微软雅黑\"><size value=\"14\">%c</size></font></color>"),'a');
strText += strMsg;
strMsg.Format(_T("<color value=\"#00FF00\"><font value=\"微软雅黑\"><size value=\"14\">%c</size></font></color>"),'b');
strText += strMsg;
strMsg.Format(_T("<color value=\"#0000FF\"><font value=\"微软雅黑\"><size value=\"14\">%c</size></font></color>"),'c');
strText += strMsg;
strMsg.Format(_T("<color value=\"#FF00FF\"><font value=\"微软雅黑\"><size value=\"14\">%c</size></font></color>"),'d');
strText += strMsg;
pEditSim->AppendFormatText(strText,FALSE);
下拉框(combobox)控件说明
基类:SComboBase 〖SWindow、ISDropDownOwner〗
属性名 |
类型 |
说明 |
dropDown |
0|1 |
是否按下 |
dropHeight |
数字 |
下拉框高度 |
curSel |
数字 |
默认选中索引 |
btnSkin |
字符串 |
按钮资源 |
animateTime |
数字 |
动画时间 |
autoFitDropBtn |
0|1 |
自适应下拉按钮大小 |
<combobox name="cbx_in_lv" pos="[10,{0,@200,@30" dropDown="1" dropHeight="300" class="cls_edit" dotted="0" animateTime="200" curSel="0">
<liststyle class="cls_edit" iconSkin="skin_menuicon" itemSkin="skin_tab_left" itemHeight="30" colorText="#000000" colorSelText="#FFFFFF" colorItemBkgnd="#FFFFFF" colorItemSelBkgnd="#000088"/>
<editstyle inset="5,0,5,0" colorText="#000000" align="left" colorBkgnd="#FFFFFF"/>
<items>
<item text="combobox.item1" icon="1" data="100"/>
<item text="combobox.item2" icon="2" data="100"/>
<item text="combobox.item3" icon="3" data="103"/>
</items>
</combobox>
注意:下拉框在调用ResetContent的时候会把编辑框上的文本清空。
下拉框高度27视觉效果和编辑框高度28差不多。
事件
EventCBSelChange::EventID
下拉框删除所有项,会出发下拉事件
列表(listbox)控件说明
属性名 |
类型 |
说明 |
scrollSpeed |
数字 |
滚动速率 |
itemSkin |
字符串 |
皮肤 |
iconSkin |
字符串 |
皮肤 |
colorItemBkgnd |
color |
表项背景色 |
colorItemBkgnd2 |
color |
表项背景色 |
colorItemSelBkgnd |
color |
选中表项背景色 |
colorText |
color |
文本颜色 |
colorSelText |
color |
选中文本颜色 |
icon-x |
数字 |
图标 x 坐标 |
icon-y |
数字 |
图标 y 坐标 |
text-x |
数字 |
文本 x 坐标 |
text-y |
数字 |
文本 y坐标 |
hotTrack |
0|1 |
鼠标移动时高亮显示下面的行(0--不支持 1--支持) |
colorItemHotBkgnd |
color |
鼠标悬留时表项背景色 |
<listbox name="lb_test" size="250,0" weight="1" hotTrack="1" itemSkin="skin_tab_left" class="cls_edit" iconSkin="skin_menuicon" itemHeight="30" colorText="#000000" colorSelText="#FFFFFF" colorItemBkgnd="#FFFFFF" colorItemSelBkgnd="#000088">
<items>
<item text="item1" icon="1" data="100"/>
<item text="item2" icon="2" data="100"/>
<item text="item3" icon="3" data="103"/>
<item text="item4" icon="4" data="100"/>
<item text="item5" icon="5" data="105"/>
<item text="item6" icon="0" data="100"/>
</items>
</listbox>
进度条(progress)控件说明
<progress name="prog_test" pos="100,100,@200,@15" font="adding:-8" value="20" min="0" max="100" showPercent="1"/>
组(group)控件说明
基类:SWindow
类名:SGroup
说明:组控件,<group colorLine1="#b8d5e2" colorLine2="#999999">group text</>。
属性名 |
类型 |
说明 |
colorLine1 |
color |
颜色 |
colorLine2 |
color |
颜色 |
round |
数字 |
半径 |
<group pos="[50,{0,@180,@100">
radio+stateMap
<radio pos="10,0" id="10000" name="radio2_1" drawFocusRect="0" skin="skin_webbtn_forward"></radio>
<radio pos="[20,{0" id="10001" name="radio2_2" drawFocusRect="0" skin="skin_webbtn_forward"></radio>
<radio pos="[20,{0" id="10002" name="radio2_3" drawFocusRect="0" skin="skin_webbtn_forward"></radio>
<radio pos="10,[10" id="10003" name="radio2_4" drawFocusRect="0" checked="1" skin="skin_webbtn_forward"></radio>
<radio pos="[20,{0" id="10004" name="radio2_5" drawFocusRect="0" skin="skin_webbtn_forward"></radio>
<radio pos="[20,{0" id="10005" name="radio2_6" drawFocusRect="0" skin="skin_webbtn_forward"></radio>
</group>
<group text="combobox" size="-1,-1" layout="vbox" padding="10,10,10,10">
<combobox name="cbx_test" size="250,30" dropDown="1" dropHeight="100" class="cls_edit" dotted="0" animateTime="200" curSel="2">
<liststyle class="cls_edit" iconSkin="skin_menuicon" itemSkin="skin_tab_left" itemHeight="30" colorText="#000000" colorSelText="#FFFFFF" colorItemBkgnd="#FFFFFF" colorItemSelBkgnd="#000088"/>
<editstyle inset="5,0,5,0" colorText="#000000" align="left" colorBkgnd="#FFFFFF"/>
<items>
<item text="combobox.item1" icon="1" data="100"/>
<item text="combobox.item2" icon="2" data="100"/>
<item text="combobox.item3" icon="3" data="103"/>
<item text="combobox.item4" icon="4" data="100"/>
<item text="combobox.item5" icon="5" data="105"/>
<item text="combobox.item6" icon="0" data="100"/>
</items>
</combobox>
<!--on_btn_select_cbx 在lua脚本中运行-->
<button size="-2,25" extend_top="10" on_command="on_btn_select_cbx">setcursel(-1)</button>
</group>
标签(tabctrl)控件说明
基类:SWindow
类名:STabPage
控件名:page
属性名 |
类型 |
说明 |
title |
字符串 |
标题(只能在 STabCtrl 中使用) |
基类:SWindow
类名:STabCtrl
属性名 |
类型 |
说明 |
curSel |
数字 |
选中索引 |
tabHeight |
数字 |
tab 高度 |
tabWidth |
数字 |
tab 宽度 |
tabPos |
数字 |
tab 开始偏移 |
framePos |
坐标 |
坐标 |
tabInterSize |
数字 |
tab 标签间隙 |
tabInterSkin |
字符串 |
分割线皮肤 |
tabSkin |
字符串 |
tab 皮肤 |
iconSkin |
字符串 |
icon 皮肤 |
frameSkin |
字符串 |
框架皮肤 |
icon-x |
数字 |
图标 x 坐标 |
icon-y |
数字 |
图标 y 坐标 |
text-x |
数字 |
文本 x 坐标 |
text-y |
数字 |
文本 y 坐标 |
tabAlign |
top left |
显示方式 |
animateSteps |
int |
动画切换页面时动画次数 |
<tabctrl name="tab_main" pos="5,30,-5,-5" interpolator="Decelerate" curSel="0" focusable="0" animateSteps="30" animateType="1" tabHeight="75" tabSkin="skin_tab_main" text-y="50" iconSkin="skin_page_icons" icon-x="10" colorTextHover="#ff0000" fontHover="italic:1" fontPush="adding:1,bold:1">
<page title="页面1">
<include src="layout:page_ctrls"/>
</page>
<page title="页面2" tip="页面2">
<include src="layout:page_animator"/>
</page>
<page title="页面3" tip="页面3">
<include src="layout:page_layout"/>
</page>
</tabctrl>
当切换页面时会触发一个消息EventTabSelChanged::EventID。
bool OnTabSelChanged(EventArgs *pEvt);
EVENT_NAME_HANDLER(L"tab_sound", EventTabSelChanged::EventID, OnTabSelChanged)
bool CEventHandlerSound::OnTabSelChanged(EventArgs *pEvt)
{
EventTabSelChanged *pEvt2 = sobj_cast<EventTabSelChanged>(pEvt);
if (pEvt2)
{
CSettingConfig::Instance().SetKeyValue(L"nCurSelTabIndex", L"tabSound",pEvt2->uNewSel);
return true;
}
return false;
}
列表(listctrl)控件说明
基类:SWindow
类名:SHeaderCtrl
控件名:header
属性名 |
类型 |
说明 |
itemSkin |
字符串 |
皮肤 |
sortSkin |
字符串 |
皮肤 |
fixWidth |
0|1 |
是否固定宽度(0--否 1--是) |
itemSwapEnable |
0|1 |
是否允许调整位置(0--禁止 1--允许) |
基类:SPanel
类名:SListCtrl
控件名:listctrl
属性名 |
类型 |
说明 |
headerHeight |
数字 |
表头高度 |
itemHeight |
数字 |
表项高度 |
itemSkin |
字符串 |
皮肤 |
colorItemBkgnd |
color |
表项背景色 |
colorItemBkgnd2 |
color |
表项背景色 |
colorItemSelBkgnd |
color |
选中表项背景色 |
colorText |
color |
文本颜色 |
colorSelText |
color |
选中文本颜色 |
icon-x |
数字 |
图标 x 坐标 |
icon-y |
数字 |
图标 y 坐标 |
text-x |
数字 |
文本 x 坐标 |
text-y |
数字 |
文本 y 坐标 |
hotTrack |
0|1 |
鼠标移动时高亮显示下面的行(0--不支持 1--支持) |
<listctrl name="lc_test" hotTrack="1" pos="10,0,-10,-10" itemHeight="20" headerHeight="30" cursor="CUR_TST" font="underline:1" itemSkin="skin_tab_left" sbSkin="skin_new_scrollbar">
<header align="left" itemSwapEnable="1" fixWidth="0" sortHeader="1" itemSkin="skin_lcex_header">
<items>
<item width="150">name</item>
<item width="150">gender</item>
<item width="150">age</item>
<item width="150">score</item>
</items>
</header>
</listctrl>
设置多选及复选
<listctrl name="listSelected" hotTrack="1" size="-2,-2" itemHeight="30" headerHeight="30" multiSelection="1" checkBox="1" checkSkin="_skin.sys.checkbox">
<header align="center" itemSwapEnable="0" fixWidth="0" sortHeader="0">
<items>
<item width="50">序号</item>
<item width="50">模块</item>
<item width="520">配置文件</item>
</items>
</header>
</listctrl>
右键菜单事件
EventCtxMenu
EVT_CTXMENU
多列列表(mclistview)说明
<mclistview name="mclv" size="-2,0" weight="1" colorBkgnd="#ffffff" headerHeight="40" sbSkin="image_vscrollbar_png">
<header align="center" itemSwapEnable="1" fixWidth="0" font="underline:0,adding:-3" sortHeader="1" colorBkgnd="#ffffff" itemSkin="skin_lcex_header">
<items>
<item width="100">检测项</item>
<item width="500">简介</item>
<item width="95">状态</item>
<item width="100">操作</item>
</items>
</header>
<template itemHeight="100" colorHover="#cccccc" colorSelected="#0000ff">
<window name="col1" clipClient="1" layout="hbox" gravity="center">
<text name="txtItem" size="-1,-1" font="bold:1,adding:-1">系统</text>
</window>
<window name="col2" clipClient="1" layout="hbox" gravity="center">
<text name="txtDescription" size="-1,-1" font="adding:-5">windows</text>
</window>
<window name="col3" clipClient="1" layout="hbox" gravity="center">
<text name="txtStates" size="-1,-1" font="adding:-4" align="center">已安装</text>
</window>
<window name="col4" clipClient="1" layout="hbox" gravity="center">
<check name="checkOperate" size="60,28">禁用</check>
</window>
</template>
</mclistview>
头文件
#ifndef __MC_ADAPTER_H__
#define __MC_ADAPTER_H__
#include <vector>
#include <helper/SAdapterBase.h>
struct CheckInformation
{
SStringW strItem;
SStringW strDescription;
SStringW strStates;
};
class CMcAdapter : public SMcAdapterBase
{
public:
CMcAdapter();
~CMcAdapter();
void DeleteItem(int iPosition);
protected:
virtual int getCount();
virtual void getView(int position, SWindow * pItem, pugi::xml_node xmlTemplate);
SStringW GetColumnName(int iCol) const;
private:
std::vector<CheckInformation> m_CheckInformation;
};
#endif
源文件
#include "stdafx.h"
#include "MCAdapter.h"
CMcAdapter::CMcAdapter()
{
CheckInformation info[] =
{
{ L"系统", L"window系统信息", L"已安装"},
{ L"ASIO", L"ASIO信息", L"已安装"},
{ L"HID", L"HID信息", L"已安装"}
};
for (int i = 0; i < 3; i++)
{
m_CheckInformation.push_back(info[i]);
}
}
CMcAdapter::~CMcAdapter()
{
}
int CMcAdapter::getCount()
{
return m_CheckInformation.size();
}
void CMcAdapter::getView(int position, SWindow * pItem, pugi::xml_node xmlTemplate)
{
if (pItem->GetChildrenCount() == 0)
{
pItem->InitFromXml(xmlTemplate);
}
CheckInformation information = m_CheckInformation.at(position);
pItem->FindChildByName(L"txtItem")->SetWindowText(information.strItem);
pItem->FindChildByName(L"txtDescription")->SetWindowText(information.strDescription);
pItem->FindChildByName(L"txtStates")->SetWindowText(information.strStates);
}
void CMcAdapter::DeleteItem(int iPosition)
{
if (iPosition >= 0 && iPosition < getCount())
{
m_CheckInformation.erase(m_CheckInformation.begin() + iPosition);
notifyDataSetChanged();
}
}
SStringW CMcAdapter::GetColumnName(int iCol) const
{
return SStringW().Format(L"col%d", iCol + 1);
}
使用
BOOL CMainDlg::OnInitDialog(HWND hWnd, LPARAM lParam)
{
m_bLayoutInited = TRUE;
SMCListView* pMCListView = FindChildByName2<SMCListView>(L"mclv");
if (pMCListView)
{
IMcAdapter* pAdapter = new CMcAdapter;
pMCListView->SetAdapter(pAdapter);
pAdapter->Release();
}
return 0;
}
树控件(treectrl)说明
属性名 |
类型 |
说明 |
indent |
数字 |
缩进字符数 |
itemHeight |
数字 |
表项高度 |
itemMargin |
位置(margin 相对位置,比如说上,下,左,右) |
|
checkBox |
0|1 |
是否有复选框(0--没有 1--有) |
rightClickSel |
0|1 |
右击选中(0--不支持 1--支持) |
itemBkgndSkin |
color |
表项背景色 |
itemSelSkin |
字符串 |
皮肤 |
toggleSkin |
字符串 |
皮肤 |
iconSkin |
字符串 |
皮肤 |
checkSkin |
字符串 |
皮肤 |
colorItemBkgnd |
color |
表项背景色 |
colorItemSelBkgnd |
color |
表项背景色 |
colorrItemText |
color |
表项背景色 |
colorItemSelText |
color |
表项背景色 |
<treectrl size="-2,-2" name="mytree" itemHeight="30" iconSkin="skin_tree_icon" checkBox="1" font="underline:1">
<item text="组织机构" img="0" selImg="1" expand="1">
<item text="市场部" img="0" selImg="1">
<item text="南一区" img="2"/>
<item text="北二区" img="2"/>
<item text="西三区" img="2">
<item text="第一分队" img="0" selImg="1" expand="0">
<item text="张三组" img="2"/>
<item text="李四组" img="2"/>
<item text="王五组" img="2"/>
</item>
</item>
</item>
</item>
<item text="宣传部" img="0" selImg="1" expand="0">
<item text="南一区" img="2"/>
<item text="北二区" img="2"/>
<item text="西三区" img="2"/>
</item>
</treectrl>
树控件事件汇总
EVT_TC_SELCHANGING=15000,
EVT_TC_SELCHANGED,
EVT_TC_EXPAND,
EVT_TC_CHECKSTATE,
EVT_TC_DBCLICK, //treectrl的叶子节点双击事件
右键菜单事件
EventCtxMenu
EVT_CTXMENU
左键点击事件
EventTCSelChanged
EVT_TC_SELCHANGED
双击事件
EventTCDbClick
EVT_TC_DBCLICK
EVT_TC_SELCHANGING
EventTCSelChanging
EVT_TC_EXPAND
EventTCExpand
EVT_TC_CHECKSTATE
EventTCCheckState
具体对照查看在源码event.h中。
树控件拓展(treeview)
xml文件
<window pos="5,[2,-5,-5">
<treeview pos="0,0,-0,-0" name="tree_view_00" itemHeight="-1" colorItemBkgnd="#FFFFFF" colorItemSelBkgnd="#cccccc" indent="30">
<template height="60" colorHover="#cccccc" colorSelected="#0000ff" trackMouseEvent="1">
<toggle pos="[0,|0,@20,@20" offset="0,-0.5" name="tgl_switch" skin="_skin.sys.tree.toggle" tip="show how to use switch"/>
<button pos="[0,5,@150,@25" name="btn_test" tip="click">btn</button>
<text pos="[20,{0" colorText="#ff0000" name="txt_red">text item</text>
</template>
</treeview>
</window>
代码
#pragma once
#include <helper/SAdapterBase.h>
struct TreeItemData
{
SStringW strName;
int nAge;
SStringT strTstLong;
};
class CTreeViewAdapter :public STreeAdapterBase<TreeItemData>
{
public:
CTreeViewAdapter()
{
TreeItemData data;
data.strName = L"name root";
data.nAge = 100;
HSTREEITEM hRoot = InsertItem(data);
SetItemExpanded(hRoot, FALSE);
for (int i = 0; i < 100; i++)
{
data.strName.Format(L"branch_%d", i);
data.nAge++;
data.strTstLong = _T("red text");
InsertItem(data, hRoot);
}
}
~CTreeViewAdapter()
{
}
virtual void getView(SOUI::HTREEITEM loc, SWindow * pItem, pugi::xml_node xmlTemplate)
{
if (pItem->GetChildrenCount() == 0)
{
pItem->InitFromXml(xmlTemplate);
}
ItemInfo & ii = m_tree.GetItemRef((HSTREEITEM)loc);
SWindow * pWnd = pItem->FindChildByName(L"btn_test");
SASSERT(pWnd);
pWnd->SetWindowText(S_CW2T(ii.data.strName));
SWindow *pTxtRed = pItem->FindChildByName(L"txt_red");
SASSERT(pTxtRed);
pTxtRed->SetWindowText(ii.data.strTstLong);
SToggle *pSwitch = pItem->FindChildByName2<SToggle>(L"tgl_switch");
SASSERT(pSwitch);
pSwitch->SetVisible(HasChildren(loc));
pSwitch->SetToggle(IsItemExpanded(loc));
pSwitch->GetEventSet()->subscribeEvent(EVT_CMD, Subscriber(&CTreeViewAdapter::OnSwitchClick, this));
}
bool OnSwitchClick(EventArgs *pEvt)
{
SToggle *pToggle = sobj_cast<SToggle>(pEvt->sender);
SASSERT(pToggle);
SItemPanel *pItem = sobj_cast<SItemPanel>(pToggle->GetRoot());
SASSERT(pItem);
SOUI::HTREEITEM loc = (SOUI::HTREEITEM)pItem->GetItemIndex();
ExpandItem(loc, ITvAdapter::TVC_TOGGLE);
return true;
}
};
用法
STreeView * pTreeView = FindChildByName2<STreeView>("tree_view_00");
if (pTreeView)
{
CTreeViewAdapter * pTreeViewAdapter = new CTreeViewAdapter;
pTreeView->SetAdapter(pTreeViewAdapter);
pTreeViewAdapter->Release();
}
事件
点击
pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_CLICK,Subscriber(&CTreeViewAdapter::OnClick,this));
双击
pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_DBCLICK,Subscriber(&CTreeViewAdapter::OnDBClick,this));
右键
pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_RCLICK,Subscriber(&CTreeViewAdapter::OnRClick,this));
悬留
pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_HOVER,Subscriber(&CTreeViewAdapter::OnHover,this));
离开
pItem->GetEventSet()->subscribeEvent(EVT_ITEMPANEL_LEAVE,Subscriber(&CTreeViewAdapter::OnLeave,this));
界面
在main窗口中右键弹出菜单
//soui消息
EVENT_MAP_BEGIN()
EVENT_NAME_HANDLER(L"tree_view_00", EVT_CTXMENU, OnCtxMenu)
EVENT_MAP_END()
void OnCtxMenu(EventArgs* pArgs);
void CMainDlg::OnCtxMenu(EventArgs* pArgs)
{
STreeView* pTree = (STreeView*)pArgs->sender;
SASSERT(pTree);
EventCtxMenu *pEvt2 = sobj_cast<EventCtxMenu>(pArgs);
POINT pt = pEvt2->pt;
CPoint cPt = pt;
SItemPanel* pPanel = pTree->HitTest(cPt);
SMenuEx menu;
menu.LoadMenu(L"smenu:menu");
ClientToScreen(&pt);
menu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd);
}
想要获取控件里面的数据,调用CTreeData * pPanel = (CTreeData*) pPanel ->GetUserData();
菜单(menu)说明
<menuRoot ncSkin="image_bg_round_white_png" trCtx="main_menu" itemHeight="26dp" iconPos="4dp,4dp" textOffset="5dp" iconBarWidth="24dp" maxWidth="200dp" minWidth="100dp" margin="1,1,1,1" itemSkin="skin_btn_1_bg_png" colorText="#FFFFFFFF">
<menuItem id="50" text="添加命令"/>
<menuItem id="51" text="删除 "/>
<menuItem id="52" text="执行"/>
<menuItem id="53" check="0" text="重命名"/>
<sep/>
</menuRoot>
其中sep是separator的缩写,代表分隔符。
注意id不能为0,不然进不了OnCommand函数。
uires.idx
<SMENU>
<file name="menu" path="xml\menu.xml"/>
</SMENU>
头文件
EVENT_NAME_COMMAND(L"btn_menu", OnMenu)
MSG_WM_COMMAND(OnCommand)
源文件
void CMainDlg::OnMenu()
{
SmenuEx menu; //注意menu不能为成员变量,如果设置成成员变量,翻译的时候会出错
if (menu.LoadMenu(L"SMENU::menu"))
{
if (!m_bIsEnglish)
{
menu.CheckMenuItem(7, MF_BYCOMMAND | MF_CHECKED);
menu.CheckMenuItem(8, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
menu.CheckMenuItem(7, MF_BYCOMMAND | MF_UNCHECKED);
menu.CheckMenuItem(8, MF_BYCOMMAND | MF_CHECKED);
}
CRect rcBtn;
SButton * btn = FindChildByName2<SButton>(L"btn_menu");
if (btn)
{
rcBtn = btn->GetWindowRect();
}
CPoint pt;
pt.x = rcBtn.left;
pt.y = rcBtn.bottom;
ClientToScreen(&pt);
menu.TrackPopupMenu(0,pt.x,pt.y,m_hWnd);
}
}
右键菜单
CPoint pt;
GetCursorPos(&pt);
menu.TrackPopupMenu(0, pt.x, pt.y, m_pHostWnd->m_hWnd);
nRet = menu.TrackPopupMenu(TPM_RETURNCMD,pt.x,pt.y,commonApp->m_pMainHideWnd->m_hWnd);
TPM_RETURNCMD是等选择菜单项的时候才会返回。
也可以动态的添加菜单项,即加载菜单成功之后添加如下代码
menu.InsertMenu(0, MF_BYPOSITION, 3001, L"清除音效");
menu.InsertMenu(1, MF_BYPOSITION, 3002, L"修改名字");
menu.InsertMenu(2, MF_BYPOSITION, 3003, L"删除按钮");
菜单命令响应函数
void CMainDlg::OnCommand(UINT uNotifyCode, int nID, HWND wndCtl)
{
if (uNotifyCode == 0)
{
if (nID == 101)
{
;
}
}
}
自由移动窗口说明
属性名 |
类型 |
说明 |
captionHeight |
数字 |
标题栏高度 |
captionSkin |
字符串 |
标题栏皮肤 |
resizable |
0|1 |
改变窗口大小 |
vAlign |
数字 |
垂直排列方式 |
hAlign |
数字 |
水平排列方式 |
distX |
数字 |
|
distY |
数字 |
<freeMoveWindow name="fmw_test" margin="5,25,5,5" clipClient="1" captionHeight="20" colorBorder="#cccccc" width="160" height="100" valign="0x20" halign="0x01" distx="20" disty="20" colorBkgnd="#660000">
<text pos="|0,|0" offset="-0.5,-0.5" multilines="1" colorText="#ff00ff">drag and resize\n the host to see\n what will happen.</text>
</freeMoveWindow>
托盘控件
<menu iconSkin="skin_traymenu_icons" itemHeight="26" iconMargin="4" textMargin="8">
<item id="1" check="1">导出配置</item>
<item id="2" radio="1">导入配置</item>
<item id="3" disable="1">检查更新</item>
<item id="4">这是测试菜单1</item>
<sep/>
<item id="5">
帮助与反馈
<item id="51" icon="0">访问官网</item>
<item id="52" icon="1">帮助指南</item>
<item id="53" icon="2">错误提交</item>
<item id="54" icon="3">关于SOUI</item>
</item>
<sep/>
<item id="6">退出</item>
</menu>
<shellnotifyicon id="110" menu="SMENU:menu_tray" ico="ICON_LOGO:16" tip="110"/>
SOUI总结之控件说明相关推荐
- 拓展SOUI中SImRichEdit控件的视频OLE控件(VideoOle)
视频定位控件数据可分为两部分: 可见部分:播放按钮.加载按钮.视频第一帧图片.视频时长 不可见部分:视频URL 以下为VideoOle控件头文件部分: extern "C" con ...
- SOUI的一个动态创建控件的小例子
涉及知识点: 获取可用的屏幕个数以及分辨率 SOUI中的线性布局的使用 SOUI中的动态插入xml的方法(也就是动态的创建控件) 对动态创建出来的控件,进行一个点击事件的注册 目的:获取屏幕个数,生成 ...
- android 模糊查询控件_第三十二篇:在SOUI2.0中像android一样使用资源
SOUI2.0之前,在SOUI中使用资源通常是直接使用这个资源的name(一个字符串)来引用.使用字符串的好处在于字符串能够表达这个资源的意义,因此使用字符串也是现代UI引擎常用的方式.尽管直接使用字 ...
- Qt---布局,设置控件边距,拉伸因子
QGridLayout *LeftLayout =new QGridLayout(this); LeftLayout->addWidget(label1, 0, 0); //label1在第1行 ...
- HarmonyOS 字体在自身控件中居中(使用text_alignment)
要实现的效果就是把字体在控件居中 HarmonyOS 使用的是text_alignment 属性,详细的如下 text_alignment 文本对齐方式 left 表示文本靠左对齐. 可以设置取值项 ...
- Android 如何防止用户同时点击多个控件问题
qa 测试说 一次连点不同的控件,app 多个控件分别有响应 这个问题处理方法也是很简单 就是在布局里面添加 android:splitMotionEvents="false"a ...
- Android中设置控件可见与不可见详解
通常控件的可见与不可见分为三种情况. 第一种 gone 表示不可见并且不占用空间 第二种 visible 表示可见 第三种 invisible 表示不可见但是占用空间 可见与不可见的表现形式有两种. ...
- 文本类控件(EditView 的介绍)
EditView的作用:用于在屏幕上显示文本输入框 Android的编辑框组件组件可以输入单行文本,多行文本,指定格式文本(密码,邮箱地址等) 2中使用方法 1 java代码中通过new关键字创建 2 ...
- 文本类控件 (TextView的介绍)
TextView的作用:用于在屏幕上显示文本 Android中的文本框组件可以显示单行文本,多行文本,也可以显示带图像的文本 使用的2中方法 1 java代码中通过new关键字创建 2 XML布局中使 ...
最新文章
- 快速人体姿态估计--Pose Proposal Networks
- c:forEach 如何输出序号
- Android HAL 开发 (2)
- tomcat测试程序的安装
- Javascript特效:关闭小广告
- 利用sklearn对红酒数据集分类
- 广义线性模型 逻辑回归与softmax的推导
- 计算机分磁盘,磁盘分区怎么分
- 空格、NBSP 造成的 JSON 解析失败问题
- 基于2017年亚太建模比赛A题数据的多种分类模型评价
- 微软快捷键截图_所有最好的Microsoft Excel键盘快捷键
- Dissect HTTP3
- Linux 安装中文 man 手册
- HDL语言三种描述方式--结构化描述方式、数据流描述方式、行为级描述方式
- python安装出错0xc00006b_python 装不起来,提示0x80240017错误,咋办?
- Android手机app的adb命令测试电量
- ubyntu 链接mysql_ubuntu下mysql连接(转载)
- 打印机种类与对应的耗材
- 自定义View之指南针(反编译别人的代码实现)
- CSS Grid 布局