Hello!
I have trouble in using CListCtrl. I can?t Insert the Image Item at
second or another column.
I set this ListCtrl 'Report' Type. At Report type, only first column
display the item. At second column, the image didn't displayed,
however I inser the image item.
I can?t know the reason. I?ll show you the source code.
BOOL CTmpTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_SkinList.InsertColumn(1, "???", LVCFMT_LEFT, 50);
m_SkinList.InsertColumn(2, "?????", LVCFMT_LEFT, 100);
ListView_SetExtendedListViewStyle(m_SkinList.m_hWnd,
LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
m_oLargeImage.Create(32, 32, ILC_COLOR4, 3, 3);
m_oSmallImage.Create(16, 16, ILC_COLOR4, 3, 3);
CBitmap cBit;
cBit.LoadBitmap(IDB_BITMAP1);
m_oLargeImage.Add(&cBit, RGB(255,255,255));
cBit.DeleteObject();
cBit.LoadBitmap(IDB_BITMAP2);
m_oSmallImage.Add(&cBit, RGB(255,255,255));
cBit.DeleteObject();
m_SkinList.SetImageList(&m_oLargeImage, LVSIL_NORMAL);
m_SkinList.SetImageList(&m_oSmallImage, LVSIL_SMALL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CTmpTestDlg::OnButton1()
{
int nCount=m_SkinList.GetItemCount();
m_SkinList.SetRedraw(FALSE);
CString* pstr = new CString;
pstr->Format("1?");
LPCTSTR psz = *pstr;
m_SkinList.InsertItem(LVIF_IMAGE, nCount, 0, 0, 0, 0, 0);
m_SkinList.SetItem(nCount, 1, LVIF_IMAGE|LVIF_PARAM|LVIF_TEXT, psz, 0,
0, 0, reinterpret_cast<LPARAM>(pstr));
delete pstr;
m_SkinList.SetRedraw(TRUE);
} |