Issue about CListVIew and CImageList

Category: VC/MFC -> Graphics Processing/Algorithm Author: xuezhe123a Date: 2010-07-31 01:51:14
 
xuezhe123a
2010-07-31 01:51:14
Why   all   the   rows   have   same   icon  ?

void   CProcessExplorerView :: OnInitialUpdate ()
{
CListViewEx :: OnInitialUpdate ();
CListCtrl &   ListCtrl   =   GetListCtrl ();

m_SmallImageList.Create (16,   16, ILC_COLORDDB | ILC_MASK | ILC_COLOR24,   10,5);

int   i,   j;
LV_COLUMN   lvc;

lvc.mask   =   LVCF_FMT   |   LVCF_WIDTH   |   LVCF_TEXT   |   LVCF_SUBITEM ;

for (i   =   0;   i < NUM_COLUMNS;   i ++)
{
lvc.iSubItem   =   i;
lvc.pszText   =   _gszColumnLabel [i];
lvc.cx   =   _gnColumnWidth [i];
lvc.fmt =   _gnColumnAlign [i];
ListCtrl.InsertColumn (i, & lvc);
}

ProcessExplorerHelper   helper;
m_Processes = helper.EnumProcess ();

//m_SmallImageList.SetOverlayImage (2,   1);
for (list < Process > :: iterator   iter = m_Processes.begin (); iter = m_Processes.end ();! iter ++)
{
// if (iter- >! m_IconSmall = NULL)
// {
m_SmallImageList.Add (iter- > m_IconSmall);
//}

}

 
ListCtrl.SetImageList (& m_SmallImageList,   LVSIL_SMALL);
  CString   str;
str.Format (_TEXT (" % d "), m_SmallImageList.GetImageCount ());
OutputDebugString (str);
 

i = 0;
for (list < Process >: : iterator   iter = m_Processes.begin (); iter = m_Processes.end (); iter ++)
{
LV_ITEM   lvi;
lvi.mask   =   LVIF_TEXT   | & nbsp! ; LVIF_IMAGE  ;
lvi.iItem   =   i;
lvi.iSubItem   =   0;
lvi.pszText   = (LPWSTR) iter- > pe32.szExeFile;
lvi.iImage   =   i;
lvi.stateMask   =   LVIS_STATEIMAGEMASK;
lvi.state   =   INDEXTOSTATEIMAGEMASK (1);

ListCtrl.InsertItem (& lvi);
i ++;
}

i = 0;
for (list < Process > :: iterator   iter = m_Processes. begin (); iter = m_Processes.end ();! iter ++)
{
/ * for (j   =   1;   j < NUM_COLUMNS;   j ++)
{
ListCtrl.SetItemText (i, j, _gszItem [i] [j]);
} * /
CString   str;
str.Format (_T ("% d "), iter- > pe32.th32ProcessID);
ListCtrl.SetItemText (i, 1, (LPCTSTR) str);

str.Format (_T ("% d   K "), iter- > pmc32.PrivateUsage / 1024);
ListCtrl.SetItemText (i, 3, (LPCTSTR) str);

str.Format (_T ("% d   K "), iter- > pmc32.WorkingSetSize / 1024);
ListCtrl.SetItemText (i, 4, (LPCTSTR) str);

iter- > FileVersion.GetInfo ( );

CString   desc;
iter- > FileVersion.GetFileDescription   (desc);
ListCtrl.SetItemText (i, 5, (LPCTSTR) desc);

CString   companyName;
iter- > FileVersion.GetCompanyName   (companyName);
ListCtrl.SetItemText (i, 6, (LPCTSTR) companyName);

i ++;
}

CWinThread   * pthread = AfxBeginThread (WorkThread,
(LPVOID) this);

// updatewindow
}
greenpanda123
2010-07-31 02:31:03
Check   the   m_SmallImageList   variable,   is   there   only   one   image   in   this  ? list