Initialization
void C__dlg::initctllist ()
{
cimagelist* m_pimagelist = new CImageList ();
M_pimagelist->create (+, ilc_color8| Ilc_mask, 2, 2);
Add an icon to M_pimagelist
M_pimagelist->add (AfxGetApp ()->loadicon (Idi_icon1));
M_pimagelist->add (AfxGetApp ()->loadicon (Idi_icon2));
M_list. SetImageList (M_pimagelist, Lvsil_small);
M_list. SetExtendedStyle (m_list. GetExtendedStyle () | Lvs_ex_subitemimages)////Set up extension style children have pictures
M_list. InsertColumn (0, _t ("Name"), Lvcfmt_center);
M_list. InsertColumn (1, _t ("state"), Lvcfmt_center);
M_list. InsertColumn (2, _t ("Address"), Lvcfmt_center);
M_list. InsertColumn (3, _t ("Port"), Lvcfmt_center);
CRect rect;
M_list. GetClientRect (&rect);
int nwidth = rect. Width ();
M_list. Setcolumnwidth (0, nwidth*25/100);
M_list. Setcolumnwidth (1, nwidth*20/100);
M_list. Setcolumnwidth (2, nwidth*35/100);
M_list. Setcolumnwidth (3, nwidth*20/100);
}
Add a line with a picture note the implementation of the "subkey"
void C__dlg::onbuttonadd ()
{
Todo:add your control notification handler code here
Add a new user
M_list. InsertItem (M_gindex, "Auris",-1); Always add in-1
Lvitem item;
Item.mask = Lvif_image;
Item.iitem = M_gindex;
Item.isubitem = 1;
item.iimage = 0;
M_list. SetItem (&item);
M_list. Setitemtext (M_gindex, 2, "127.0.0.1");
M_list. Setitemtext (M_gindex, 3, "827");
m_gindex++;
}
[00019]-[2015-09-14]-[00]-[List control ' subkey ' displays the implementation of the icon]