1. First, use classwizard to create a clistctrl derived class and add the following to the header file message response function:
// Generated message map Functions
Protected:
// {Afx_msg (cscanfilelist) //} afx_msg
Afx_msg void oncustomdraw (nmhdr * pnmhdr, lresult * presult );
Declare_message_map ()
2. Add the class implementation file accordingly:
Begin_message_map (cscanfilelist, clistctrlex)
// {Afx_msg_map (cscanfilelist)
...
On_policy_reflect (nm_customdraw, oncustomdraw)
...
//} Afx_msg_map
End_message_map ()
3. function implementation:
Void cscanfilelist: oncustomdraw (nmhdr * pnmhdr, lresult * presult)
{
Nmlvcustomdraw * plvcd = reinterpret_cast <nmlvcustomdraw *> (pnmhdr );
// Take the default processing unless we
// Set this to something else below.
* Presult = cdrf_dodefault;
// First thing-check the draw stage. If it's the control's prepaint
// Stage, then tell windows we want messages for every item.
If (cdds_prepaint = plvcd-> nmcd. dwdrawstage)
{
* Presult = cdrf_policyitemdraw;
}
Else if (cdds_itemprepaint = plvcd-> nmcd. dwdrawstage)
{
// Only compare the text here. Note: Index = plvcd-> nmcd. dwitemspec
If (getitemtext (plvcd-> nmcd. dwitemspec, 2) = m_lpszencrypt)
{
Plvcd-> clrtext = RGB (255, 0, 0 );
Plvcd-> clrtextbk = RGB (255, 0, 0 );
}
// Tell windows to paint the control itself.
* Presult = cdrf_dodefault;
}
}