Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CListCtrl to display icons in a dialog.

Status
Not open for further replies.

programmer2002

Programmer
Apr 29, 2002
6
SG
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;
}
 
Make sure you've got the LVS_REPORT style bit turned on if you're in Report view... Only thing I can think of. You may add columns, but they won't appear without tickling that bit.

I hope that helps. CoolNameDenied
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top