spacefuxx
July 3rd, 2007, 10:02 AM
Hello everyone,
i'm programing an MCF process viewer. By now, everything works fine except that the ICONS of the processes don't show up (just an empty room).
I am using the ExtractIconEx API call for getting the ICON's.
This is a screenshot on which you can see what i mean:
http://www.imagebanana.com/view/1ooamz42/processmirror.JPG
And these are the code snippets (i guess the error is in the last one) :
LVCOLUMN column;
column.mask= LVCF_TEXT | LVCF_WIDTH | LVCF_FMT;
column.fmt= LVCFMT_LEFT;
column.cx= 50;
column.pszText= "PID";
m_listctrl.InsertColumn(0, &column);
column.cx= 400;
column.pszText= "Image Path";
m_listctrl.InsertColumn(1, &column);
m_listctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
LVITEM item;
item.mask=LVIF_TEXT | LVIF_IMAGE;
item.iItem=0;
item.iSubItem=0;
item.pszText="1999"; // process identifier (PID)
int nitem =m_listctrl.InsertItem(&item);
m_listctrl.SetItemText(nitem, 1, "c:\\myfile.exe"); // Image Path
HICON smallicon;
ExtractIconEx("c:\\myfile.exe", 0, NULL, &smallicon, 1);
CImageList imagelst;
imagelst.Create(16, 16, ILC_COLOR, 1, 1);
int iconno = imagelst.Add(smallicon);
m_listctrl.SetImageList(&imagelst, LVSIL_SMALL);
m_listctrl.SetItem(nitem, 1, LVIF_IMAGE, NULL, iconno, 0, 0, 0, 0);
DestroyIcon(smallicon);
i'm programing an MCF process viewer. By now, everything works fine except that the ICONS of the processes don't show up (just an empty room).
I am using the ExtractIconEx API call for getting the ICON's.
This is a screenshot on which you can see what i mean:
http://www.imagebanana.com/view/1ooamz42/processmirror.JPG
And these are the code snippets (i guess the error is in the last one) :
LVCOLUMN column;
column.mask= LVCF_TEXT | LVCF_WIDTH | LVCF_FMT;
column.fmt= LVCFMT_LEFT;
column.cx= 50;
column.pszText= "PID";
m_listctrl.InsertColumn(0, &column);
column.cx= 400;
column.pszText= "Image Path";
m_listctrl.InsertColumn(1, &column);
m_listctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
LVITEM item;
item.mask=LVIF_TEXT | LVIF_IMAGE;
item.iItem=0;
item.iSubItem=0;
item.pszText="1999"; // process identifier (PID)
int nitem =m_listctrl.InsertItem(&item);
m_listctrl.SetItemText(nitem, 1, "c:\\myfile.exe"); // Image Path
HICON smallicon;
ExtractIconEx("c:\\myfile.exe", 0, NULL, &smallicon, 1);
CImageList imagelst;
imagelst.Create(16, 16, ILC_COLOR, 1, 1);
int iconno = imagelst.Add(smallicon);
m_listctrl.SetImageList(&imagelst, LVSIL_SMALL);
m_listctrl.SetItem(nitem, 1, LVIF_IMAGE, NULL, iconno, 0, 0, 0, 0);
DestroyIcon(smallicon);