"UI Guy" wrote:
Lubomir wrote:
After sorting my listcontrol, the function FindItem will always
return -1
when looking for and item that is not on the top.
I set up LVFINDINFO as follows:
flags = LVFI_STRING | LVFI_WRAP;
psz = mystring;
Can you give an example showing you inserting a single item into an
empty list control, then searching for it? What do you mean by
"sorting my listcontrol"? Are you doing something other than setting
the sort attribute?
I have 2 columns, I can sort them when the header is clicked.
Inserting:
nIndex = InsertItem(GetItemCount(), sztext, nIcon);
CMyObject *pObj = new CMyObject();
... initialize pObj...
SetItem(nIndex, nColumn, LVIF_TEXT, szText, 0, 0, 0, 0);
SetItemData(nIndex, (LPARAM)pObj);
Searching for an Item:
LVFINDinfo info;
info.flags = LVFI_STRING | LVFI_WRAP;
info. psz = mystring;
FindItem(&info);
or
CMyObject *myObj= new CMyObject();
... initialize myObj...
info.flags = LVFI_PARAM;
info. lParam = myObj;
FindItem(&info);
It doesn't work.
However, if I use GetItemData(i) what will return CMyObject object, and
the
when I look for this object, it will work.
it seems, like Find compares the pointers (address) only and not the
contents of object.
Regards,
Lubomir