April 19, 2024, 02:45:03 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


listview finditem needed

Started by ExMember001, August 04, 2006, 12:15:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ExMember001

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.

sapero

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();
}

ExMember001

thanx, seems my mistake was the -1 and the & ;)

ExMember001

lol how did you know my listview was named lv1 ;)

ExMember001

August 04, 2006, 03:25:47 PM #4 Last Edit: August 04, 2006, 03:38:05 PM by krypt
got it .. working great ;)

ExMember001

August 04, 2006, 03:57:58 PM #5 Last Edit: August 04, 2006, 04:00:20 PM by krypt
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;
}