http://www.purebasic.fr/german/viewtopic.php?t=8805
j'ai adapté à ma sauce.
Code : Tout sélectionner
;#################################
;##### LISTICONGADGET FILTER #####
;#################################
#LVM_GETHEADER = (#LVM_FIRST+31)
#HDI_FILTER = $0100
#HDFT_ISSTRING = $0000
#HDS_FILTERBAR = $0100
#HDM_SETFILTERCHANGETIMEOUT = #HDM_FIRST+22
#HDM_EDITFILTER = #HDM_FIRST+23
#HDM_CLEARFILTER = #HDM_FIRST+24
#HDN_FILTERCHANGE = #HDN_FIRST-12
#HDN_FILTERBTNCLICK = #HDN_FIRST-13
Structure HDITEM
mask.l
cxy.l
pszText.l
hbm.l
cchTextMax.l
fmt.l
lParam.l
iImage.l
iOrder.l
type.l
pvFilter.l
EndStructure
Structure HDTEXTFILTER
pszText.s
cchTextMax.l
EndStructure
Procedure.l ListIconGadget_CallBack(hwnd.l, msg.l, wParam.l, *lParam.NMHDFILTERBTNCLICK)
Protected Result.l, item.HDITEM, filter.HDTEXTFILTER
Result = CallWindowProc_(GetProp_(hwnd, "USER_OLDPROC"), hwnd, msg, wParam, *lParam)
If msg = #WM_NOTIFY
Select *lParam\hdr\code
Case #HDN_FILTERCHANGE, #HDN_FILTERBTNCLICK
filter\pszText = Space(256)
filter\cchTextMax = 256
item\mask = #HDI_FILTER
item\type = #HDFT_ISSTRING
item\pvFilter = @filter
SendMessage_(GetProp_(hwnd, "USER_HEADER"), #HDM_GETITEM, *lParam\iItem, @item)
If GetProp_(hwnd, "USER_HPROC")
CallFunctionFast(GetProp_(hwnd, "USER_HPROC"), filter\pszText, *lParam\iItem)
EndIf
EndSelect
EndIf
ProcedureReturn Result
EndProcedure
Procedure.l ListIconGadget_Filter(gadget.l, *window, *hProc, timeOut.l = 50)
Protected *header, hdItem.HDITEM
*header = SendMessage_(GadgetID(gadget), #LVM_GETHEADER, #Null, #Null)
If *header
hdItem\mask = #HDI_FILTER
hdItem\type = #HDFT_ISSTRING
SendMessage_(*header, #HDM_SETFILTERCHANGETIMEOUT, 0, timeOut)
SetWindowLong_(*header, #GWL_STYLE, GetWindowLong_(*header, #GWL_STYLE) | #HDS_FILTERBAR )
SetProp_(*window, "USER_OLDPROC", SetWindowLong_(*window, #GWL_WNDPROC, @ListIconGadget_CallBack()))
SetProp_(*window, "USER_HEADER", *header)
SetProp_(*window, "USER_HPROC", *hProc)
EndIf
EndProcedure
;#################################
;##### EXAMPLE D'UTILISATION #####
;#################################
Procedure.l recherche(text.s, column.l)
If ExamineEnvironmentVariables()
ClearGadgetItemList(1)
While NextEnvironmentVariable()
Select column
Case 0: EnvironmentVariable$ = EnvironmentVariableName()
Case 1: EnvironmentVariable$ = EnvironmentVariableValue()
EndSelect
If text = #Null$ Or FindString(LCase(EnvironmentVariable$), LCase(text), 1)
AddGadgetItem(1, -1, EnvironmentVariableName() + #LF$ + EnvironmentVariableValue())
EndIf
Wend
EndIf
StatusBarText(0, 0, "La recherche de '" + text + "' a retournée " + Str(CountGadgetItems(1)) + " résultat(s).")
EndProcedure
If OpenWindow(0, 0, 0, 640, 400, "Variables d'environnement", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If CreateStatusBar(0, WindowID(0))
AddStatusBarField(800)
EndIf
If CreateGadgetList(WindowID(0))
ListIconGadget(1, 5, 5, WindowWidth(0)-10, 370, "Nom", 180, #PB_ListIcon_FullRowSelect)
AddGadgetColumn(1, 1, "Valeur", WindowWidth(0)-215)
ListIconGadget_Filter(1, WindowID(0), @recherche())
EndIf
recherche(#Null$, #Null)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf