It is currently Tue Jun 02, 2020 7:02 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Template for history of Find
PostPosted: Thu Sep 14, 2017 11:07 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 635
Location: china
updated 3 time
Template for history of Find
Code:
;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

_________________
my pb for chinese:
http://ataorj.ys168.com


Last edited by gurj on Sat Sep 30, 2017 2:34 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Template for history of Find
PostPosted: Sat Sep 30, 2017 2:37 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 635
Location: china
optimised
updated 2 for 1 optimised:'ElseIf g1=-1' to 'Else'
updated 1 for 1 wrong.

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye