Add code in the DrawItem () function of the CListCtrl derived class Cmylistctrl
CDC *PDC = Cdc::fromhandle (lpdrawitemstruct->HDC); if(Lpdrawitemstruct->itemstate &&lvis_selected) {CPen penline (ps_solid,1, RGB (0,0,0)); CPen*oldpenline = Pdc->selectobject (&penline); Rcitem.right-=2; Rcitem.bottom-=2; PDC-MoveTo (Rcitem.left, rcitem.top); PDC-LineTo (Rcitem.right, rcitem.top); PDC-MoveTo (Rcitem.left, rcitem.top); PDC-LineTo (Rcitem.left, Rcitem.bottom); PDC-MoveTo (Rcitem.left, Rcitem.bottom); PDC-LineTo (Rcitem.right, Rcitem.bottom); PDC-MoveTo (Rcitem.right, rcitem.top); PDC-LineTo (Rcitem.right, Rcitem.bottom); Pdc->selectobject (oldpenline);Rcitem.deflaterect (2,2,2,2); COLORREF M_color= RGB ( in,173,255); for(inti = Rcitem.height ()/2; I>0; i--) {CPen pen (ps_solid,1, M_color); CPen*oldpen = Pdc->selectobject (&pen); PDC->moveto (Rcitem.left, Rcitem.top +i); PDC->lineto (rcitem.right, Rcitem.top +i); PDC->moveto (Rcitem.left, Rcitem.bottom-i); PDC->lineto (Rcitem.right, Rcitem.bottom-i); PDC-SelectObject (Oldpen); } PDC->settextcolor (RGB (255,255,255)); } Else{PDC->settextcolor (RGB (0,0,0)); CBrush Brush; Brush. CreateSolidBrush (RGB (255,255,255)); PDC->fillrect (RcItem, &brush); } CString StrText= GetItemText (Nrow,0); CRect Rcsubitem; Getsubitemrect (Nrow,0, Lvir_label, Rcsubitem); PDC->drawtext (StrText, Rcsubitem, Dt_center);
Penline is in the frame inside the line, imitating the look of the selected
The Linetype of an entity
Ps_solid Solid Line
Ps_dash Dashed Line
Ps_dot Dot Line
Ps_dashdot Line
Ps_dashdotdot Double-line
Self-painted Listctrl control selects the row highlight (simulates windows)