主界面
使用
TabLayout
进行设置需要切换的xml
布局,如下述a.xml
b.xml
c.xml
d.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<?xml version="1.0" encoding="utf-8"?> <Window size="1056,700" sizebox="4,4,6,6" roundcorner="0,0" caption="0,0,0,20" bktrans="false" mininfo="1056,700" showshadow="true" shadowimage="imgs/main/shadow.png" shadowsize="6" shadowcorner="8,8,8,8" bkcolor2="#FF181818" bkcolor="#FF181818"> <VerticalLayout name="root"> <VerticalLayout name="body"> </VerticalLayout> <HorizontalLayout mouse="false" float="0,0,1,0" inset="0,0,0,0" height="44" name="sysbtnLayout" > <VerticalLayout mouse="false" > <HorizontalLayout height="10"/> <HorizontalLayout mouse="false" > <HorizontalLayout mouse="false" /> <Button padding="12,0,0,0" name="helpbtn" width="20" height="20" tooltip="帮助" normalimage="imgs/btn/help0.png" hotimage="imgs/btn/help1.png" pushedimage="imgs/btn/help2.png"/> <Button padding="12,0,0,0" name="minbtn" width="20" height="20" tooltip="最小化" normalimage="imgs/btn/minimize0.png" hotimage="imgs/btn/minimize1.png" pushedimage="imgs/btn/minimize2.png"/> <Button padding="12,0,0,0" name="maxbtn" width="20" height="20" tooltip="最大化" normalimage="imgs/btn/maximization0.png" hotimage="imgs/btn/maximization1.png" pushedimage="imgs/btn/maximization2.png"/> <Button padding="12,0,0,0" name="restorebtn" width="20" height="20" tooltip="还原" visible="false" normalimage="imgs/btn/reduction0.png" hotimage="imgs/btn/reduction1.png" pushedimage="imgs/btn/reduction2.png"/> <Button padding="12,0,0,0" name="closebtn2" width="20" height="20" tooltip="关闭" normalimage="imgs/btn/close0.png" hotimage="imgs/btn/close1.png" pushedimage="imgs/btn/close2.png"/> <HorizontalLayout width="12"/> </HorizontalLayout> </VerticalLayout> </HorizontalLayout> <HorizontalLayout> <Button name="btn1" bkcolor="#FFCCFF99"/> <Button name="btn2" bkcolor="#FF0099CC"/> <Button name="btn3" bkcolor="#FFCC0033"/> </HorizontalLayout> <HorizontalLayout> <VerticalLayout bkcolor="#ff445566"> <TabLayout name="tab1"> <Include source="a.xml"/> <Include source="b.xml"/> </TabLayout> </VerticalLayout> <VerticalLayout bkcolor="#7f445566"> <TabLayout name="tab2"> <Include source="c.xml"/> <Include source="d.xml"/> </TabLayout> </VerticalLayout> </HorizontalLayout> </VerticalLayout> </Window> |
布局文件
a.xml
1 2 3 4 5 6 7 8 9 10 11 12 |
<?xml version="1.0" encoding="utf-8"?> <Window > <VerticalLayout name="root" bkcolor="#FFFFCC99"> <Control/> <HorizontalLayout> <Control/> <Label text="albert"/> <Control/> </HorizontalLayout> <Control/> </VerticalLayout> </Window> |
b.xml
1 2 3 4 5 6 7 8 9 10 11 12 |
<?xml version="1.0" encoding="utf-8"?> <Window > <VerticalLayout name="root" bkcolor="#FFCCCCCC"> <Control/> <HorizontalLayout> <Control/> <Label text="aet"/> <Control/> </HorizontalLayout> <Control/> </VerticalLayout> </Window> |
切换控制
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
void CMainWnd::Notify(TNotifyUI& msg) { // 消息类型 if (msg.sType == _T("click")) { // 控件名称 CDuiString sName = msg.pSender->GetName(); if (sName == _T("btn1")) { auto prt = reinterpret_cast<CTabLayoutUI*>(m_pm.FindControl(_T("tab1"))); prt->SelectItem(1); } else if (sName == _T("btn2")) { auto prt = reinterpret_cast<CTabLayoutUI*>(m_pm.FindControl(_T("tab1"))); prt->SelectItem(0); } else if (sName == _T("btn3")) { //others } } WindowImplBase::Notify(msg); } |
文件结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
│ aet_ac.exe │ aet_ac.ilk │ aet_ac.pdb │ DuiLib_d.dll │ DuiLib_d.lib │ └─skin │ a.xml │ b.xml │ c.xml │ d.xml │ main.xml │ └─imgs │ animation.png │ home_avatar.png │ ├─btn │ ├─main │ └─sysbtn |
本文为原创文章,版权归Aet所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ System_系统是否为64位操作系统10/19
- ♥ 2025_03_1103/11
- ♥ 大话数据结构_线性表_双向链表11/01
- ♥ breakpad记述:Windows07/27
- ♥ 2023_02_0902/11
- ♥ Electron学习一04/03