Okay, here goes - this is on the OnInitialUpdate func. of my view class
(form view)
Excuse my shoddy code, when I hit this 'speed bump' I didn't clean it up
before I could get SetItem to work, which it still doesn't.
Again I really appreciate you all having a look!
I added variables to view class - CListCtrl List, CImageList ilist....
////////////////////////////////////////////////////////////////////////////////////////////////////////
CRect rect;
CRect lrect;
GetWindowRect(rect);
List.Create(WS_CHILD|WS_VISIBLE|LVS_OWNERDRAWFIXED|LVS_REPORT,CRect(10,30,(rect.Width()-10),(rect.Height()-50)),this,0);
ilist.Create(IDB_ILIST1,6,2,RGB(255,0,255));
List.SetImageList(&ilist,LVSIL_SMALL);
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_SUBITEMIMAGES );
List.GetWindowRect(lrect);
int w = lrect.Width();
List.InsertColumn(0,"Sender",0,int(w*.2));
List.InsertColumn(1,"Subject",0,int(w*.4));
List.InsertColumn(2,"Date",0,int(w*.2));
List.InsertColumn(3,"Size",0,int(w*.05));
List.InsertColumn(4,NULL,0,20);
///////////////////////
CHeaderCtrl* pHead = List.GetHeaderCtrl();
pHead->SetImageList(&ilist);
HDITEM hdi;
pHead->GetItem(4,&hdi);
hdi.mask |=HDI_IMAGE|HDI_FORMAT;
hdi.fmt |=HDF_IMAGE|HDF_CENTER;
hdi.fmt &=~HDF_STRING;
hdi.iImage=0;
pHead->SetItem( 4, &hdi); //////////////////////////////<---- This works
List.SetItem(0,0,LVIF_IMAGE, NULL, 1, 0, 0, 0);////<----This doesn't :-(
///////////////////////////////////////////////////////
I tried to see if SetItemText works - it doesn't either. Very perplexing.
Thanks a million
b
Post by Tom SerfaceThanks I'll look and I'm sure others will as well. Hopefully, it's
something simple that you're just overlooking.
Tom
Post by saywhatYes and yes.
I set LVS_EX_SUBITEMIMAGES
I attached the image list to the list ctrl.
I then used SetItem as indicated.
Both the list ctrl and the image were added to my view class as variables.
This is holding up my whole project. I will try and post my exact code
here later.
Thanks for your efforts!!!!
b
Post by Tom SerfaceIt's difficult to say without seeing your actual code. Are you setting
the style to allow subitem images in the extended styles. Do you have
the latest version of Internet Explorer (above 4.1) that supports this
feature?
Tom
Post by saywhatBoy this is really vexing me. PS thanks Tom for your help...
I've pored through the docs again, to no avail. I have a feeling there's
something I'm missing somewhere. I know the list class is created properly.
Just want to slip a bitmap froma an imagelist into a column.
The imagelist is valid because I used it in the header control, voila, there
it is, I can point to eash of the 4 images in the list without a problem.
Again TIA,.,,,
Bruce
Post by Tom SerfaceThis article describes a CListCtrl extension that allows you to have
https://secure.codeproject.com/listctrl/ReportControl.asp
Specifically, in the Q&A at the bottom a user asked the same question and
used these statements..CListCtrl m_ListFirst;
DWORD dwStyle
=m_ListFirst.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE,0,0);
dwStyle |= LVS_EX_FULLROWSELECT|LVS_EX_SUBITEMIMAGES;
m_ListFirst.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE,0,dwStyle);
and then....
m_ListFirst.SetItem(nItem, nSubItem, LVIF_IMAGE, NULL, nImage, 0, 0, 0);
http://www.codeguru.com/Cpp/controls/listview/advanced/article.php/c4179/
Tom
Post by saywhatI have looked all around, and still can't see why this doesn't work.
I want to simply insert an image in a column of my list control. I can't
seem to get my image past the first subitem, even if I use the LVITEM
structure. It will display the images denoted fromthe image list, bu
only in the first column.
Also when I use SetImageList for my control, The first image ion the list
always appears before any text I insert in the first column. If I
comment out the SetImageList function, no image appears (duh).
Any ideas....TIA
b