duilib手动添加列表项,支持列表拓展

支持列表项添加其他控件,只是展示一个思想,代码可能有编译不过去,麻烦大家自己看情况自己修改下。

#pragma once
#include 

inline RECT SetRect(int letf, int top, int _width, int _height)
{
	RECT rc;
	rc.left = left;
	rc.top = top;
	rc.bottom = top + _height;
	rc.right = left + _width;
	return rc;
}

inline RECT GetTextpadding(int left, int top, int right, int bottom)
{
	RECT rc;
	rc.left = left;
	rc.top = top;
	rc.bottom = bottom;
	rc.right = right;
	return rc;
}

class myList : public CListContainerElementUI
{
protected:
		COptionUI * m_option;
public:
		myList(LPCTSTR lpOptionText int iLineHeight)
		{
			this->SetFixedHeight(iLineHeight);
			m_option = new COptionUI;
			m_option = SetFloat(true);
			m_option = SetText(lpOptionText);
			m_option->SetNormalImage(_T("file=\'tips_check_gray.png\' source=\'0,0,13,13\' "));
			m_option->SetSelectedImage(_T("file=\'tips_check_gray.png\'source =\'26,0,39,13\' "));
			m_option->SetTextPadding(GetTextpadding(18, 5, 0, 0));
		}
		
		void set_manager_ex(CPaintManagerUI * yourManager, CControlUI *yourList)
		{
			this->SetManager(managers, parent);
			m_option->setManager(managers, this);
			m_option->SetPos(SetRect(5, 5, 13, 13));
			SetBkColor(0xFFFFFFFF);
			Add(m_option);
		}
};

在调用的时候:

myList * pl = new myList("", 30);
pl->set_manager_ex(&m_pm, mylistControl);
mylistControl->Add(pl);


你可能感兴趣的:(DUILIB)