透明的CheckBox,基类是CButton...
主要代码如下
OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rect;
GetClientRect(&rect);
CRect BoxRect;
BoxRect=rect;
BoxRect.right =BoxRect.left +15;
dc.DrawFrameControl(BoxRect,DFC_BUTTON,DFCS_BUTTONCHECK|GetCheck()?DFCS_CHECKED :0);
CFont myFont;
myFont.CreatePointFont (120,_T("宋体"));
CFont *pOldFont=(CFont *)dc.SelectObject (&myFont);
dc.SetBkMode(TRANSPARENT);
CString StrWndText;
GetWindowText(StrWndText);
rect.OffsetRect (20,0);
dc.DrawText(StrWndText, rect, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
dc.SelectObject (pOldFont);
myFont.DeleteObject ();
// Do not call CButton::OnPaint() for painting messages
}