Visual C++ and MFC Fundamentals Chapter 21: Tree and List Controls
lvColumn.iImage = 0;
m_List.InsertColumn(0, &lvColumn);
lvColumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvColumn.fmt = LVCFMT_LEFT;
lvColumn.cx = 100;
lvColumn.pszText = "Profession";
m_List.InsertColumn(1, &lvColumn);
lvColumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_IMAGE;
lvColumn.fmt = LVCFMT_LEFT | LVCFMT_IMAGE;
lvColumn.iImage = 1;
lvColumn.cx = 80;
lvColumn.pszText = "Fav Sport";
m_List.InsertColumn(2, &lvColumn);
lvColumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvColumn.fmt = LVCFMT_LEFT;
lvColumn.cx = 75;
lvColumn.pszText = "Hobby";
m_List.InsertColumn(3, &lvColumn);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
To use bitmaps or icons on a list control’s items, you should first create bitmaps or icons.
If you do not plan to use the Report view and you want to use bitmaps, you can create a
long bitmap that will made of small pictures of the same size. Each picture will be used
for each item. Normally, each picture should have a size of 16x16 or less. An example
would be:
This bitmap is made of 6 pictures of the same dimensions. If you do not plan to use the
Report view and you plan to use icons, create each icon with a 16x16 size.