Source code and executable file: Http://files.cnblogs.com/rainboy2010/CRadioListBox.zip
The main code is as follows:
voidCradiolistbox::D rawitem (lpdrawitemstruct lpdrawitemstruct) {CDC* PDC = Cdc::fromhandle (lpdrawitemstruct->HDC); if(Lpdrawitemstruct->itemid = = (UINT)-1) { if(Lpdrawitemstruct->itemaction & Oda_focus) Pdc->drawfocusrect (&lpDrawItemStruct->RcItem); return; } Else { intSelchange = lpdrawitemstruct->itemaction &Oda_select; intFocuschange = lpdrawitemstruct->itemaction &Oda_focus; intDrawentire = lpdrawitemstruct->itemaction &Oda_drawentire; BOOL sel= Lpdrawitemstruct->itemstate &ods_selected; if(Selchange | |Drawentire) {CString strText; GetText (lpDrawItemStruct-itemid,strtext); PDC->fillsolidrect (&lpdrawitemstruct->rcitem,:: GetSysColor ((Getexstyle () &ws_ex_transparent)?Color_btnface:color_window)); //Draw radio Button intH = lpdrawitemstruct->rcitem.bottom-lpdrawitemstruct->Rcitem.top; CRect Rect (lpdrawitemstruct->rcitem.left+2, lpdrawitemstruct->rcitem.top+2, lpDrawItemStruct->rcitem.left+h-3, lpdrawitemstruct->rcitem.top+h-3); PDC->drawframecontrol (&rect, Dfc_button, Dfcs_buttonradio | (sel?) Dfcs_checked:0)); PDC-SetTextColor (Color_windowtext); PDC-SetBkMode (TRANSPARENT); lpDrawItemStruct->rcitem.left + =h; PDC->drawtext (StrText, &lpdrawitemstruct->rcitem, dt_left| dt_vcenter|dt_singleline); } if(Focuschange && lpdrawitemstruct->itemstate & Ods_focus &&sel) {PDC->drawfocusrect (&lpDrawItemStruct->RcItem); } }}
Control self-painted Cradiolistbox