Template for history of Find
Code: Select all
;line51 add SetGadgetState(1,0):g1=0,ok,for win pb5.61
;ComboBoxGadget() bug To pbIDE's Find/Replace bug
;also try line17 to ComboBoxGadget(1, 105, 0, 305, 25);,#PB_ComboBox_Editable)
; For [Find],If Not use SetGadgetState(1,0):g1=0
; will is bug Or wrong.
; because If Removed Item=GetGadgetState(1) And Item>-1,Editable will=""
; see line38:
; If g1>0
; RemoveGadgetItem(1,g1+1)
; optimised and update to:
; Template for history of Find
; http://www.purebasic.fr/english/viewtopic.php?f=12&t=69173
OpenWindow(0, 0, 0, 415, 140, "Find", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(0, 30, 5, 70, 25, "Search for:")
ComboBoxGadget(1, 105, 0, 305, 25,#PB_ComboBox_Editable)
ButtonGadget(2, 5, 110, 100, 25, "Find Next")
For a=0 To 3
AddGadgetItem(1,a,Str(a))
Next
SetGadgetText(1,"-1")
g1=GetGadgetState(1)
#maxCount=5;CountGadgetItems(1)<=#maxCount;********
Repeat:ev=WaitWindowEvent():Select ev
Case #PB_Event_Gadget:eg=EventGadget()
Select eg
Case 1:g1=GetGadgetState(1)
Case 2:g1s.s= GetGadgetText(1)
If g1s<>"":If g1<>0
b=CountGadgetItems(1)
AddGadgetItem(1,0,g1s)
;-{**********:
If g1>0
RemoveGadgetItem(1,g1+1)
;}**********
Else;g1=-1
For a=1 To b
If GetGadgetItemText(1,a,0)=g1s
RemoveGadgetItem(1,a):Break
EndIf
If b=#maxCount
RemoveGadgetItem(1,#maxCount)
EndIf
Next
EndIf
SetGadgetState(1,0):g1=0
EndIf
;-{find in ... , add your codes here}
EndIf
EndSelect
Case #PB_Event_CloseWindow:Break
EndSelect:ForEver
End