Re: CTreeView/CTreeCtrl with Images



My guess is that LVIF_IMAGE is not set for your item in the mask telling it that you are using an image. I don't know what is in your imagelist either (from the example here) so it could just be blank if the icon is not filled out. Did you try with CLR_DEFAULT just to see if perhaps something is not blending right with the image.

Tom

"Radhika S" <RadhikaS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:39ACCC58-EC23-4D7C-9B4D-FE1C9B17F77D@xxxxxxxxxxxxxxxx
Hi,

Am also facing a similar problem. Am having a listctrl and adding a
imagelist to it. But the image is noe being displayed. I am creating the app
as a MFC smart Device app.
Please ee my code below. PLease tell mewhats the mistake and why the icon is
not displayed though i get no error. As specified in this the post i tried to
initialize the imagelist in the OnInitDialog but am not able to access it in
the eventhandler. Someone help me please. Here is the code.

BOOL CMySampleDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
mylistobj.InsertColumn(0,L"Name",LVCFMT_LEFT,50);
mylistobj.InsertColumn(1,L"Date",LVCFMT_LEFT,50);
mylistobj.InsertColumn(2,L"Size",LVCFMT_LEFT,50);


return TRUE; // return TRUE unless you set the focus to a control
}

void CMySampleDlg::OnBnClickedButton1()
{

CImageList il;
il.Create(IDI_ICON1,20,1,CLR_NONE);
mylistobj.ModifyStyle(LVS_TYPEMASK, LVS_REPORT);
mylistobj.SetImageList(&il,LVSIL_HEADER );
static CString details[5][3]={
L"aaaaaaaaaaaaaaaaaa",L"1stAug",L"20KB",
L"bbb",L"2ndAug",L"20KB",
L"ccc",L"3rdAug",L"20KB",
L"ddd",L"4thAug",L"20KB",
L"eee",L"5thAug",L"20KB",
};

int i=0;

// TODO: Add your control notification handler code here
for(i=0;i<5;i++)
{
//mylistobj.InsertItem(&lvi);
mylistobj.InsertItem(i,(LPCTSTR)details[i][0],0);
mylistobj.SetItemText(i,1,(LPCTSTR)details[i][1]);
mylistobj.SetItemText(i,2,(LPCTSTR)details[i][2]);
}

}

When a button is clicked a displaying the items in the listview mylistobj.

Thanks in Advance.
Regards,
Radhika

.