IonicWind Software

Aurora Compiler => GUI => Topic started by: ExMember001 on August 04, 2006, 12:15:13 PM

Title: listview finditem needed
Post by: ExMember001 on August 04, 2006, 12:15:13 PM
I need a way too find the item position by its text...
reason is, if you list directories for example and you want to add the numbers of files in it, if the listview is set to Autoarange and sortAscending the subitem doesnt get filled using the 0 positions method.

i've try to get the lv_finditem api message to work, but got no chance.
Title: Re: listview finditem needed
Post by: sapero on August 04, 2006, 01:12:22 PM
try this - it will search for "findme" string.
Message LVM_INSERTITEM returns item index, not sure if method InsertItem too...
LVFINDINFO li;
li.flags = LVFI_STRING;
li.psz = "findme";

int index = SendMessage(lv1->m_hwnd, LVM_FINDITEM, -1, &li);
if (index <> -1) {
lv1->EnsureVisible(index, true);
lv1->SetSel(index);
lv1->SetFocus();
}
Title: Re: listview finditem needed
Post by: ExMember001 on August 04, 2006, 02:40:45 PM
thanx, seems my mistake was the -1 and the & ;)
Title: Re: listview finditem needed
Post by: ExMember001 on August 04, 2006, 02:45:48 PM
lol how did you know my listview was named lv1 ;)
Title: Re: listview finditem needed
Post by: ExMember001 on August 04, 2006, 03:25:47 PM
got it .. working great ;)
Title: Re: listview finditem needed
Post by: ExMember001 on August 04, 2006, 03:57:58 PM
if anyone need it, here is a functiion:

you call it like that (if your listview is set as *lv1):

index = Finditem(lv1->m_hwnd,"your string");
return item position
return -1 if nothing found


//declare extern Finditem(unsigned int listview, String itemtext),int;

#define LVM_FIRST        0x1000
#define LVM_FINDITEM    (LVM_FIRST + 13)
#define LVFI_STRING      0x0002

struct LVFINDINFO
{
    unsigned int flags;
    pointer *psz;
    int lParam;
    POINT pt;
    unsigned int vkDirection;
}

global sub Finditem(unsigned int listview, String itemtext),int
{
    LVFINDINFO li;
    li.flags = LVFI_STRING;
    li.psz = itemtext;

    int index = SendMessage(listview, LVM_FINDITEM, -1, &li);
    return index;
}