1.在Default属性里面要添加滚动条的资源
<Default name="VScrollBar" value="button1normalimage="file='scrollbar.png' source='0,90,16,106' mask='#FFFF00FF'" button1hotimage="file='scrollbar.png' source='18,90,34,106' mask='#FFFF00FF'" button1pushedimage="file='scrollbar.png' source='36,90,52,106' mask='#FFFF00FF'" button1disabledimage="file='scrollbar.png' source='54,90,70,106' mask='#FFFF00FF'" button2normalimage="file='scrollbar.png' source='0,108,16,124' mask='#FFFF00FF'" button2hotimage="file='scrollbar.png' source='18,108,34,124' mask='#FFFF00FF'" button2pushedimage="file='scrollbar.png' source='36,108,52,124' mask='#FFFF00FF'" button2disabledimage="file='scrollbar.png' source='54,108,70,124' mask='#FFFF00FF'" thumbnormalimage="file='scrollbar.png' source='0,126,16,142' corner='2,2,2,2' mask='#FFFF00FF'" thumbhotimage="file='scrollbar.png' source='18,126,34,142' corner='2,2,2,2' mask='#FFFF00FF'" thumbpushedimage="file='scrollbar.png' source='36,126,52,142' corner='2,2,2,2' mask='#FFFF00FF'" thumbdisabledimage="file='scrollbar.png' source='54,126,70,142' corner='2,2,2,2' mask='#FFFF00FF'" railnormalimage="file='scrollbar.png' source='0,144,16,160' corner='2,2,2,2' mask='#FFFF00FF'" railhotimage="file='scrollbar.png' source='18,144,34,160' corner='2,2,2,2' mask='#FFFF00FF'" railpushedimage="file='scrollbar.png' source='36,144,52,160' corner='2,2,2,2' mask='#FFFF00FF'" raildisabledimage="file='scrollbar.png' source='54,144,70,160' corner='2,2,2,2' mask='#FFFF00FF'" bknormalimage="file='scrollbar.png' source='0,162,16,178' corner='2,2,2,2' mask='#FFFF00FF'" bkhotimage="file='scrollbar.png' source='18,162,34,178' corner='2,2,2,2' mask='#FFFF00FF'" bkpushedimage="file='scrollbar.png' source='36,162,52,178' corner='2,2,2,2' mask='#FFFF00FF'" bkdisabledimage="file='scrollbar.png' source='54,162,70,178' corner='2,2,2,2' mask='#FFFF00FF'" " />
2.修改Duilib的源码,在代码里面把资源加载进去
LRESULT CComboWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if( uMsg == WM_CREATE ) {
m_pm.SetForceUseSharedRes(true);
m_pm.Init(m_hWnd);
// The trick is to add the items to the new container. Their owner gets
// reassigned by this operation - which is why it is important to reassign
// the items back to the righfull owner/manager when the window closes.
m_pLayout = new CComboBodyUI(m_pOwner);
m_pLayout->SetManager(&m_pm, NULL, true);
LPCTSTR pDefaultAttributes = m_pOwner->GetManager()->GetDefaultAttributeList(_T("VerticalLayout"));
if( pDefaultAttributes ) {
m_pLayout->SetAttributeList(pDefaultAttributes);
}
pDefaultAttributes = m_pOwner->GetManager()->GetDefaultAttributeList(_T("HScrollBar"));
if (pDefaultAttributes) {
m_pm.AddDefaultAttributeList(_T("HScrollBar"), pDefaultAttributes);
}
pDefaultAttributes = m_pOwner->GetManager()->GetDefaultAttributeList(_T("VScrollBar"));
if (pDefaultAttributes) {
m_pm.AddDefaultAttributeList(_T("VScrollBar"), pDefaultAttributes);
}
AddDefaultAttributeList为加载默认资源属性
3.在Default里面要设置
shared="true"
4.在Combo属性里添加滚动条属性
<Combo name="cpucombo" vscrollbar="true" hscrollBar="true" float="true" pos="170,0,0,0" width="192" height="28" itemtextpadding="8,0,0,0" itemtextcolor="#FFb5b4b4" itemselectedtextcolor="#FFFFFFFF" itemhottextcolor="#FFFFFFFF" itemdisabledtextcolor="#FFCCCCCC" itemdisabledbkcolor="#FFFFFFFF" itembkimage="file='combo_itemback.png' source='0,0,24,24' corner='4,4,4,4'" itemselectedimage="file='combo_itemback.png' source='24,0,48,24' corner='4,4,4,4'" itemhotimage="file='combo_itemback.png' source='24,0,48,24' corner='4,4,4,4'" normalimage="file='combo_background.png' source='0,0,34,28' corner='4,4,29,4'" hotimage="file='combo_background.png' source='34,0,68,28' corner='4,4,29,4'" pushedimage="file='combo_background.png' source='68,0,102,28' corner='4,4,29,4'" disabledimage="file='combo_background.png' source='102,0,136,28' corner='4,4,29,4'" dropboxsize="0,140" >
<ListLabelElement text="Auto" />
<ListLabelElement text="1 cores" />
<ListLabelElement text="2 cores" />
<ListLabelElement text="3 cores" />
<ListLabelElement text="4 cores" />
</Combo>
深圳程序员交流群550846167