programmer2002
Programmer
Hi Gurus,
I got problem when I use CListCtrl in a dialog. I have a program which searches for files with specific extension, then loads their corresponding icon into the dialog. If there is no correspondant icon to the file, a default icon will be loaded into the dialog.
In my program, I use CImageList to contain the icons, and bind the CImageList to the ClistCtrl (see my codes below). However, when I run the program, there is no icon displaying in the dialog although they are existing on the disk. Please help me figure out the problem.
Many thanks.
BOOL CTutPanel::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
tutFile = new CTutFile();
ASSERT(tutFile != NULL);
int count = findTutorials(tutFile, m_path);
ASSERT(count != 0);
CTutFile* tmp = tutFile;
CImageList* m_pImageList = new CImageList();
ASSERT(m_pImageList != NULL);
m_pImageList->Create(32, 32, TRUE, count, count);
m_pImageList->SetImageCount(count);
int i = 0;
while(tmp != NULL){
CString fileName = tmp->tutFileName;
CString iconName = tmp->iconFileName;
...
if(iconName.CompareNoCase(_T("") == 0 ||
iconName.Find(_T(".ico") == -1 || iconName.Find(_T(".bmp") == -1)
{
// Add my bitmap, make all black pixels transparent.
CBitmap bm;
bm.LoadBitmap(IDB_TUTICON);
m_pImageList->Add(&bm, RGB(0, 0, 0));
}
else{
CBitmap bm;
bm.LoadBitmap((LPCTSTR)iconName);
m_pImageList->Add(&bm, RGB(0, 0, 0));
}
tmp->index = i;
tmp->description = m_Description;
}
tmp = tmp->nextFile;
i++;
}
m_tutContainer.SetImageList(m_pImageList, LVSIL_NORMAL);
// Set the callback mask so that only the selected and focused states
// are stored for each item.
m_tutContainer.SetCallbackMask(LVIS_SELECTED|LVIS_FOCUSED);
ASSERT(m_tutContainer.GetCallbackMask() == (LVIS_SELECTED|LVIS_FOCUSED));
return TRUE;
}
I got problem when I use CListCtrl in a dialog. I have a program which searches for files with specific extension, then loads their corresponding icon into the dialog. If there is no correspondant icon to the file, a default icon will be loaded into the dialog.
In my program, I use CImageList to contain the icons, and bind the CImageList to the ClistCtrl (see my codes below). However, when I run the program, there is no icon displaying in the dialog although they are existing on the disk. Please help me figure out the problem.
Many thanks.
BOOL CTutPanel::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
tutFile = new CTutFile();
ASSERT(tutFile != NULL);
int count = findTutorials(tutFile, m_path);
ASSERT(count != 0);
CTutFile* tmp = tutFile;
CImageList* m_pImageList = new CImageList();
ASSERT(m_pImageList != NULL);
m_pImageList->Create(32, 32, TRUE, count, count);
m_pImageList->SetImageCount(count);
int i = 0;
while(tmp != NULL){
CString fileName = tmp->tutFileName;
CString iconName = tmp->iconFileName;
...
if(iconName.CompareNoCase(_T("") == 0 ||
iconName.Find(_T(".ico") == -1 || iconName.Find(_T(".bmp") == -1)
{
// Add my bitmap, make all black pixels transparent.
CBitmap bm;
bm.LoadBitmap(IDB_TUTICON);
m_pImageList->Add(&bm, RGB(0, 0, 0));
}
else{
CBitmap bm;
bm.LoadBitmap((LPCTSTR)iconName);
m_pImageList->Add(&bm, RGB(0, 0, 0));
}
tmp->index = i;
tmp->description = m_Description;
}
tmp = tmp->nextFile;
i++;
}
m_tutContainer.SetImageList(m_pImageList, LVSIL_NORMAL);
// Set the callback mask so that only the selected and focused states
// are stored for each item.
m_tutContainer.SetCallbackMask(LVIS_SELECTED|LVIS_FOCUSED);
ASSERT(m_tutContainer.GetCallbackMask() == (LVIS_SELECTED|LVIS_FOCUSED));
return TRUE;
}