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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Icons displayed in a Dialog

Status
Not open for further replies.

programmer2002

Programmer
Apr 29, 2002
6
SG
Hi Gurus,

I created a dialog to display a list of icons in a list control. I got a problem that I failed to load the images into the dialog although all the items are inserted successfully. I mean that all the icons in the dialog are black. Please take a look at my code to see what the problem is inside.

Thanks all a lot.

m_pImageList = new CImageList();
m_pImageList->Create(32, 32, ILC_COLOR|ILC_COLORDDB, 0, count);
m_pImageList->SetImageCount(count);

while(...){
if(iconName.CompareNoCase(_T("")) == 0 ||((iconName.Find(_T(".ico")) == -1) && (iconName.Find(_T(".bmp")) == -1)))
{
HICON icon = AfxGetApp()->LoadIcon(IDI_TUTICON);
m_pImageList->Add(icon);
}
else{
if(iconName.Find(_T(".ico")) != -1){
HICON icon = (HICON)LoadImage(AfxGetInstanceHandle(), iconName, IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
m_pImageList->Add(icon);
}
else{
HBITMAP handle = (HBITMAP)LoadImage(AfxGetInstanceHandle(), iconName, IMAGE_BITMAP, 32, 32, LR_LOADFROMFILE);
CBitmap* bm = CBitmap::FromHandle(handle);
m_pImageList->Add(bm, RGB(0, 0, 0));
}
}
}
m_tutContainer.SetImageList(m_pImageList, LVSIL_NORMAL);
// Set the callback mask so that only the selected and focused states
// are stored for each item.
for(i = 0 ; i < count; i++){
CString strText;
strText.Format(TEXT(&quot;Tutorial %d&quot;), i+1);

// Insert the item, select every other item.
m_tutContainer.InsertItem(LVIF_IMAGE|LVIF_TEXT|LVIF_STATE, i, strText, (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED, i, 0);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top