Finding partial match items in a ListView

Started by Roger Garstang, July 14, 2004, 05:41:37 PM

Previous topic - Next topic

Roger Garstang

Anyone here have experience finding partial items (%LVFI_PARTIAL) in a ListView with %LVM_FINDITEM or its Macro?  I've looked over at PB and all the ones using %LVFI_PARTIAL are searching by lParam which isn't even a string???

My searches for plain ole exact strings (%LVFI_STRING) work fine.  I give it a string like "\FireFly\Samples\SiGrid" and it only comes back with that exact match.  Now say I want to have a loop searching and while it doesn't return -1 I keep searching starting from the last match.  Say a partial search with a string of "\FireFly\Samples\".  I'd expect this to return indexes of items that contain the string like: "\FireFly\Samples\Calculator", "\FireFly\Samples\MDI", "\FireFly\Samples\SiGrid", "\FireFly\Samples\TabControl", etc...but it doesn't, it returns every single item (even other items with nothing close to the string) like each call I'm just getting the next index or something???  How is %LVFI_PARTIAL supposed to work?

Right now I'm using a combination function like

Function AllowFile(ByVal start As Dword, ByVal exact As Dword, ByVal findFile As String) As Long
   Local lvFind As LV_FINDINFO
   Local findIndex As Long

   If Len(findFile)=0 Then Function= -1: Exit Function
   lvFind.flags= IIf&(exact, %LVFI_STRING, %LVFI_PARTIAL)
   lvFind.psz= StrPtr(findFile)
   findIndex= SendMessage(HWND_HTML_FILELIST, %LVM_FINDITEM, start, VarPtr(lvFind))
   If findIndex > -1 And exact= 1 Then
       If SendMessage(HWND_HTML_FILELIST, %LVM_GETITEMSTATE, findIndex, %LVIS_SELECTED) <> %LVIS_SELECTED Then findIndex= -1
   End If
   Function= findIndex
End Function


When I'm searching for exact matches I'm also wanting to know if it is selected, but partials I'm just wanting to find them with something like:


allowed= AllowFile(-1, 0, HTTPcommand)
Do While allowed > -1
   If SendMessage(HWND_HTML_FILELIST, %LVM_GETITEMSTATE, allowed, %LVIS_SELECTED)= %LVIS_SELECTED Then
       sBuffer= sBuffer + "<TR>"
       For tempHndl= 0 To 2
           sBuffer= sBuffer + "<TD>" + FF_ListView_GetItemText(HWND_HTML_FILELIST, allowed, tempHndl) + "&nbsp;</TD>"
       Next tempHndl
       sBuffer= sBuffer + "</TR>"
   End If
   allowed= AllowFile(allowed, 0, HTTPcommand)
Loop