1.让List Control有Check Box
用SetExtendedStyle方法可以设置,看代码:
(CListCtrl m_ListCtrl;)
DWORD dwStyle = m_ListCtrl.GetStyle();
dwStyle |= LVS_EX_CHECKBOXES;
m_ListCtrl.SetExtendedStyle(dwStyle);
2.让List Box有Check Box
首先www.cechina.cn,声明Control变量的时候用CCheckListBox代替CListBox。
然后CONTROL ENGINEERING China版权所有,将List Box的Has Strings属性改为True;把Ower Draw属性改为Fixed。
3.Spin Control与Edit Control的绑定
首先www.cechina.cn,要让Spin Control的Tap Order紧跟着Edit Control(就是说,Spin Control的Tap Order是Edit Control的Tap Order加1)。
然后CONTROL ENGINEERING China版权所有,设置Spin Control的Auto Buddy和Set Buddy Integer属性为True。
4.可以设置背景和
文字颜色的Static控件
从CStatic类继承一个自己的Static类www.cechina.cn,相应WM_CTLCOLOR消息。下面是代码:
.h文件:
class ClxStatic : public CStatic
{
DECLARE_DYNAMIC(ClxStatic)
public:
ClxStatic();
virtual ~ClxStatic();
afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
void SetBackColor(COLORREF clrBack);
void SetTextColor(COLORREF clrText);
protected:
DECLARE_MESSAGE_MAP()
CBrush m_brushBack;
COLORREF m_clrBack;
COLORREF m_clrText;
};
.cpp文件:
IMPLEMENT_DYNAMIC(ClxStaticwww.cechina.cn, CStatic)
ClxStatic::ClxStatic()
{
m_clrBack = ::GetSysColor(COLOR_BTNFACE);
m_clrText = ::GetSysColor(COLOR_BTNTEXT);
}
ClxStatic::~ClxStatic()
{
}
void ClxStatic::SetBackColor(COLORREF clrBack)
{
m_clrBack = clrBack;
}
void ClxStatic::SetTextColor(COLORREF clrText)
{
m_clrText = clrText;
}
BEGIN_MESSAGE_MAP(ClxStaticwww.cechina.cn, CStatic)
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()
HBRUSH ClxStatic::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
{
// TODO: Change any attributes of the DC here
m_brushBack.Detach();
m_brushBack.CreateSolidBrush(m_clrBack);
pDC->SetBkColor(m_clrBack);
pDC->SetTextColor(m_clrText);
// TODO: Return a non-NULL brush if the parent's handler shoul