[00019]-[2015-09-14]-[00]-[List control ' subkey ' displays the implementation of the icon]

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.