//单选组合框
class UILIB_API CGroupOptionUI : public CVerticalLayoutUI
{
DECLARE_DUICONTROL(CGroupOptionUI)
public:
CGroupOptionUI();
~CGroupOptionUI();
LPCTSTR GetClass() const;
LPVOID GetInterface(LPCTSTR pstrName);
void SetTextColor(DWORD dwTextColor);
DWORD GetTextColor() const;
void SetDisabledTextColor(DWORD dwTextColor);
DWORD GetDisabledTextColor() const;
void SetFont(int index);
int GetFont() const;
//
//单选框
bool Activate();
void SetEnabled(bool bEnable = true);
void DoEvent(TEventUI& event);
LPCTSTR GetGroup() const;
void SetGroup(LPCTSTR pStrGroupName = NULL);
bool IsSelected() const;
virtual void Selected(bool bSelected, bool bMsg = true);
void SetSelectedStateCount(int nCount);
int GetSelectedStateCount() const;
virtual LPCTSTR GetSelectedStateImage();
virtual void SetSelectedStateImage(LPCTSTR pStrImage);
LPCTSTR GetSelectedImage();
void SetSelectedImage(LPCTSTR pStrImage);
LPCTSTR GetSelectedHotImage();
void SetSelectedHotImage(LPCTSTR pStrImage);
LPCTSTR GetSelectedPushedImage();
void SetSelectedPushedImage(LPCTSTR pStrImage);
LPCTSTR GetSelectedForedImage();
void SetSelectedForedImage(LPCTSTR pStrImage);
//
//按钮
virtual LPCTSTR GetNormalImage();
virtual void SetNormalImage(LPCTSTR pStrImage);
virtual LPCTSTR GetHotImage();
virtual void SetHotImage(LPCTSTR pStrImage);
virtual LPCTSTR GetPushedImage();
virtual void SetPushedImage(LPCTSTR pStrImage);
virtual LPCTSTR GetFocusedImage();
virtual void SetFocusedImage(LPCTSTR pStrImage);
virtual LPCTSTR GetDisabledImage();
virtual void SetDisabledImage(LPCTSTR pStrImage);
virtual LPCTSTR GetHotForeImage();
virtual void SetHotForeImage(LPCTSTR pStrImage);
void SetStateCount(int nCount);
int GetStateCount() const;
virtual LPCTSTR GetStateImage();
virtual void SetStateImage(LPCTSTR pStrImage);
RECT GetTextPadding() const;
void SetTextPadding(RECT rc);
//
protected:
//Paint
virtual void PaintText(HDC hDC);
virtual void PaintBorder(HDC hDC);
virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
virtual void PaintStatusImage(HDC hDC);
virtual void PaintImage(HDC hDC);
private:
SIZE CalcrectSize(SIZE szAvailable);
protected:
DWORD m_dwTextColor;
DWORD m_dwDisabledTextColor;
int m_iFont;
UINT m_uTextStyle;
RECT m_rcOption;
RECT m_rcTextPadding;
bool m_bNeedEstimateSize;
//
//单选框
bool m_bSelected;
CDuiString m_sGroupName;
int m_nSelectedStateCount;
CDuiString m_sSelectedStateImage;
CDuiString m_sSelectedImage;
CDuiString m_sSelectedHotImage;
CDuiString m_sSelectedPushedImage;
CDuiString m_sSelectedForeImage;
//
//按钮
CDuiString m_sNormalImage;
CDuiString m_sHotImage;
CDuiString m_sHotForeImage;
CDuiString m_sPushedImage;
CDuiString m_sPushedForeImage;
CDuiString m_sFocusedImage;
CDuiString m_sDisabledImage;
int m_nStateCount;
CDuiString m_sStateImage;
};
class UILIB_API CGroupCheckBoxUI : public CGroupOptionUI
{
DECLARE_DUICONTROL(CGroupCheckBoxUI)
public:
CGroupCheckBoxUI();
public:
virtual LPCTSTR GetClass() const;
virtual LPVOID GetInterface(LPCTSTR pstrName);
void SetCheck(bool bCheck);
bool GetCheck() const;
public:
virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
void SetAutoCheck(bool bEnable);
virtual void DoEvent(TEventUI& event);
virtual void Selected(bool bSelected, bool bMsg = true);
protected:
bool m_bAutoCheck;
};
本代码是根据 DuiLib_Ultimate 版修改,需要的话请点击下载
看了这个代码是不是觉得眼熟,没错这个是就根据 COptionUI 和 CCheckBoxUI 而来,
但是有两个BUG,无法设置鼠标形状,还有就是图标和文字之间的边框线没有消除,看起来没那么好看,反正不影响使用,完美主义者自己改了