ok: tool for pb IDE's FindReplace bug.

Windows specific forum
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

ok: tool for pb IDE's FindReplace bug.

Post by gurj »

this is old, new code at next pose

ok: readme for first use

i use pb5.70 x86 on winxp make FindReplaceForPUB.exe

tool for pb IDE's FindReplace bug.
the bug from pb5.42 to now pb5.7, see:

[5.42] Replace by using old replace phrase fails...
viewtopic.php?f=4&t=65153
*************
in
ataorj.ys168.com
to
winXPcn_pbBug
see:
FindReplaceForPUB.7z [32kb] :
FindReplaceForPUB.exe 67,072 29,731
FindReplaceForPUB5.pb 5,803 2,279
purebasic.ico 318
readme.txt 1,708 553
*************
open IDE to set, or close IDE and edit PureBasic.prefs and Tools.prefs, consult:
in Tools.prefs:
[Tool_14]
Command = D:\exe1\PureB\bug\find\FindReplaceForPUB.exe
Arguments =
WorkingDir =
MenuItemName = FindReplaceForPUB

++++++++++++++
in PureBasic.prefs:
[ToolbarNew]
ItemCount = 30
...
Icon_15 = Menu:Find
Action_15 = Tool:FindReplaceForPUB
...
[FindWindow]
...
HistorySize = 1
;{***because my tool not use this History,
in FindReplaceForPUB.ini use :
CountStr2 = ...
Stringes2 = ...
CountStr3 = ...
Stringes3 = ...
}
------------
Last edited by gurj on Sun Jan 06, 2019 12:40 pm, edited 1 time in total.
my pb for chinese:
http://ataorj.ys168.com
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: ok: tool for pb IDE's FindReplace bug.

Post by Bisonte »

I miss a download link, or a hint where I can find it...
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Kiffi
Addict
Addict
Posts: 1353
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: ok: tool for pb IDE's FindReplace bug.

Post by Kiffi »

gurj wrote:open IDE to set, or close IDE and edit PureBasic.prefs and Tools.prefs, consult:
Obviously, you don't know there's a dialogue for that under Menu/Tools/Configure Tools...:

Image

@Bisonte: http://ys-o.ys168.com/415662559/VfSLjLl ... eForPUB.7z
Hygge
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

@Bisonte, @Kiffi:
lnk is dynamic , has time limit. best way is:
on page:
ataorj.ys168.com
can see:
winXPcn_pbBug\
click it, can see:
FindReplaceForPUB.7z [32kb]
rightClick it to choice menu "save as..." to download.

---------
sorry for my bad english, i know there's a dialogue for that under Menu/Tools/Configure Tools...:
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

updated.
add Shift+Enter to close the tool

1 open FindReplaceForPUB should
by PureBasic.exe's ToolBar or Tools menu
2 then my tool use Ctrl+F to can Enable IDE's FindReplace for get it ID.
3 working...***not use F3 and Shift+F3 ...
4 active FindReplaceForPUB.exe TITLE and Shift+Enter to close the tool, or auto close when IDE closed.
my pb for chinese:
http://ataorj.ys168.com
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: ok: tool for pb IDE's FindReplace bug.

Post by Bisonte »

gurj wrote:@Bisonte, @Kiffi:
lnk is dynamic , has time limit. best way is:
on page:
ataorj.ys168.com
can see:
winXPcn_pbBug\
click it, can see:
FindReplaceForPUB.7z [32kb]
rightClick it to choice menu "save as..." to download.

---------
sorry for my bad english, i know there's a dialogue for that under Menu/Tools/Configure Tools...:
But I can't read the chinese language ;) They are all hieroglyphs for me :mrgreen:
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

updated, all ok!
new code is this:

Code: Select all

; **********note**********
; 1 for pb5.70 IDE by gurj
; 2 open FindReplaceForPUB should by PureBasic.exe's ToolBar or Tools menu
; 3 then this tool use Ctrl+F To can Enable IDE's FindReplace for get it ID.
; 4 working...***not use F3 And Shift+F3 ***
; 5  active FindReplaceForPUB.exe TITLE And Shift+Enter To close the tool, 
;     Or auto close when IDE closed or minimize.
; 6 in this tool , ButtonG_"x" And "close" let form To screen's right and bottom, as 'hided';
;    again 'open' this tool is change 'hided' to 'show'
; ********ataorj.ys168.com*******
MutexName$ = "FindReplaceForPUB"
hMutex = CreateMutex_(0, 0, @MutexName$)
If GetLastError_() = #ERROR_ALREADY_EXISTS
 OpenPreferences(GetPathPart(ProgramFilename())+MutexName$+".ini")
 Handle=ReadPreferenceLong("Handle",-6)
 If IsWindow_(Handle)=0
  SendMessage_(win1,#WM_CLOSE,0,0)
  ClosePreferences()
  End
 EndIf
 win1=ReadPreferenceLong("win1",-7)
 cx=ReadPreferenceLong("cx",-8)
 cy=ReadPreferenceLong("cy",-9)
 SetWindowPos_(Handle,#HWND_TOP,cx,cy,0,0,#SWP_NOSIZE)
 SetWindowPos_(win1,#HWND_TOP,cx,cy,0,0,#SWP_NOSIZE)
 ClosePreferences()
End:EndIf

Han=GetForegroundWindow_()
Global s.s=Space(40960)
GetWindowText_(Han,@s,255)
If Left(s,10)<>"PureBasic "
 MessageRequester("FindReplaceForPUB",~"besides for close this tool when purebasic.exe already closed;\nopen FindReplaceForPUB should \nby PureBasic.exe's ToolBar or Tools menu")
End:EndIf
keybd_event_(#VK_CONTROL,0,0,0)
keybd_event_(#VK_F,0,0,0):Delay(150)
keybd_event_(#VK_F,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0)
Delay(250)
Handle=GetForegroundWindow_()
OpenPreferences(GetPathPart(ProgramFilename())+MutexName$+".ini")
WritePreferenceLong("Handle",Handle)

Structure gad
 h.l;gadID
 xy.l;x or y
EndStructure
Global y1,y,Dim gad(8),g,r.rect,rec.rect,NewList gads.gad(),historys=22,check;,Dim edit(1)
Procedure ListWindows(hwnd,Param)
 Protected Class$ = Space(1024)
 GetClassName_(hwnd,@Class$,Len(Class$))
 If Class$ ="Edit"
  GetWindowRect_(hwnd,rec)
  AddElement(gads())
  gads()\h = hwnd
  gads()\xy = rec\top-2000
  g+1
 ElseIf Class$ ="ComboBox"
  GetWindowRect_(hwnd,rec)
  AddElement(gads())
  gads()\h = hwnd
  gads()\xy = rec\top-1000
  g+1
 ElseIf Class$ ="Button"
  GetWindowRect_(hwnd,rec)
  If rec\bottom>y
   AddElement(gads())
   gads()\h = hwnd
   gads()\xy = rec\left
   g+1
  ElseIf rec\top<y1; And rec\left<x1
   If SendMessage_(hwnd,#BM_GETCHECK,0,0)=0
   ;SendMessage_(hwnd,#BM_SETCHECK,1,0)
   SendMessage_(hwnd,#BM_CLICK ,0,0):EndIf
   check=hwnd:EnableWindow_(hwnd,0)
  EndIf
 EndIf
 ProcedureReturn #True
EndProcedure
;EnableMenuItem_(GetSystemMenu_(Han, #False), #SC_MINIMIZE, #MF_BYCOMMAND | 1)
;EnableMenuItem_(GetSystemMenu_(Handle, #False), #SC_CLOSE, #MF_BYCOMMAND | 1)
GetWindowRect_(Handle,r)
;x1=r\left+30
y1=r\top+60+GetSystemMetrics_(#SM_CYCAPTION)
y=r\bottom-25
r\right=r\right-r\left
r\bottom=r\bottom-r\top

win1=OpenWindow(1,0,0,0,0,"FindReplaceForPUB",#PB_Window_SystemMenu|#PB_Window_Maximize)
GetWindowRect_(win1,rec)
cx=rec\right-r\right
cy=rec\bottom-r\bottom-25
cy>>1
cx_=rec\right-60
cy_=rec\bottom-18
EnumChildWindows_(Handle,@ListWindows(),0)
SortStructuredList(gads(), 0, OffsetOf(gad\xy), TypeOf(gad\xy))
g=0
ForEach gads()
 gad(g)=gads()\h:g+1
Next

MapWindowPoints_(0,Handle,rec,2)
TextGadget(10,0,0,r\right,rec\top,"")
SetGadgetColor(10,#PB_Gadget_BackColor,$BFBFBF)
SetWindowLongPtr_(Win1, #GWL_EXSTYLE,GetWindowLongPtr_(win1, #GWL_EXSTYLE) | #WS_EX_LAYERED)
SetLayeredWindowAttributes_(Win1, $BFBFBF,0, #LWA_COLORKEY)

For a=2 To 3:GetWindowRect_(gad(a),rec):MapWindowPoints_(0,Handle,rec,2)
 ComboBoxGadget(a,rec\left ,rec\top,rec\right-rec\left ,rec\bottom-rec\top,#PB_ComboBox_Editable)
 b=ReadPreferenceLong("CountStr"+a,0)
 s=ReadPreferenceString("Stringes"+a,"")
 For c=1 To b
  AddGadgetItem(a,-1,StringField(s,c,Chr(1)))
 Next: SendMessage_(gad(a-2),#EM_GETLINE, 0, @s)
 SetGadgetText(a,s):Next

For a=4 To 8:GetWindowText_(gad(a),@s,255)
 GetWindowRect_(gad(a),rec):MapWindowPoints_(0,Handle,rec,2)
 ButtonGadget(a,rec\left ,rec\top,rec\right-rec\left ,rec\bottom-rec\top,s)
Next
SetWindowLongPtr_(win1,#GWLP_HWNDPARENT,Handle)

WritePreferenceLong("win1",win1)
WritePreferenceLong("cx",cx)
WritePreferenceLong("cy",cy)
SetWindowPos_(Handle,#HWND_TOP,cx,cy,0,0,#SWP_NOSIZE)
SetWindowPos_(win1,#HWND_TOP,cx,cy,r\right,r\bottom,#SWP_SHOWWINDOW)
;SendMessage_(gad(8),#CB_ADDSTRING,0,@s)
Procedure history(n)
 For a=0 To CountGadgetItems(n)-1
  If GetGadgetItemText(n,a)=s
   RemoveGadgetItem(n,a)
   Break
  EndIf
 Next:AddGadgetItem(n,0,s):If CountGadgetItems(n)>historys
 RemoveGadgetItem(n,CountGadgetItems(n)-1):EndIf
 While WindowEvent():Wend
 SetGadgetState(n,0)
 While WindowEvent():Wend
EndProcedure
ClosePreferences()
SetWindowColor(1,$DEB5FF)
AddKeyboardShortcut(1,#PB_Shortcut_Shift|#PB_Shortcut_Return,1)
While WindowEvent():Wend
Repeat:re:
 Select WaitWindowEvent(3600000);60 minute for check Handle close
  Case #PB_Event_Gadget:eg=EventGadget()
   Select eg
;     Case 2,3
;      If EventType()=#PB_EventType_Change
;      edit(eg)=1:EndIf
    Case 4,5:Gosub fin
    Case 6,7:s=GetGadgetText(3):history(3)
;      SendMessage_(gad(1),#EM_SETSEL, 0, -1)
;      SendMessage_(gad(1),#EM_REPLACESEL,0,s)
     SendMessage_(gad(1),#WM_SETTEXT, 0, @s)
     Gosub fin
    Case 8:If IsWindow_(Handle)
    SetWindowPos_(Handle,#HWND_TOP,cx_,cy_,0,0,#SWP_NOSIZE)
    SetWindowPos_(win1,#HWND_TOP,cx_,cy_,0,0,#SWP_NOSIZE)
   Else:Break
   EndIf
   EndSelect
   
  Case #PB_Event_CloseWindow
   If IsWindow_(Handle)
    SetWindowPos_(Handle,#HWND_TOP,cx_,cy_,0,0,#SWP_NOSIZE)
    SetWindowPos_(win1,#HWND_TOP,cx_,cy_,0,0,#SWP_NOSIZE)
   Else:Break
   EndIf
  Case 0
   If IsWindow_(Handle)=0:Break
   EndIf
  Case #PB_Event_MoveWindow
   SetWindowPos_(Handle,#HWND_TOP,WindowX(1),WindowY(1),0,0,#SWP_NOSIZE)
  Case #PB_Event_Menu:EnableWindow_(check,1)
   SetWindowPos_(Handle,#HWND_TOP,cx,cy,0,0,#SWP_NOSIZE):Break
  Case #WM_NCLBUTTONDBLCLK
   SetWindowPos_(Handle,#HWND_TOP,cx,cy,0,0,#SWP_NOSIZE)
   SetWindowPos_(win1,#HWND_TOP,cx,cy,r\right,r\bottom,#SWP_SHOWWINDOW)
   While WindowEvent():Wend
  Case #PB_Event_ActivateWindow
;   MyWindpl.WINDOWPLACEMENT 
;   MyWindpl\length=SizeOf(MyWindpl) 
;   If GetWindowPlacement_(han,@MyWindpl) And MyWindpl\showCmd=#SW_SHOWMINIMIZED
;     SetWindowState(1,#PB_Window_Minimize) 
;   EndIf

GetWindowRect_(Han,rec);:MessageRequester("",Str(rec\left))
If rec\left<-4000:SetWindowPos_(Handle,#HWND_TOP,cx_,cy_,0,0,#SWP_NOSIZE)

 Break
 ;SetWindowLongPtr_(win1,#GWLP_HWNDPARENT,0)
;SetWindowLongPtr_(win1,#GWLP_HWNDPARENT,Handle)

;    SetWindowState(1,#PB_Window_Minimize)
;     SetWindowPos_(win1,#HWND_TOP,cx_,cy_,0,0,#SWP_NOSIZE)
;     SetWindowPos_(han,#HWND_TOP,cx_,cy_,0,0,#SWP_NOSIZE)
;     While WindowEvent():Wend
   EndIf
EndSelect:ForEver

OpenPreferences(GetPathPart(ProgramFilename())+MutexName$+".ini")
For a=2 To 3:b=CountGadgetItems(a)
 WritePreferenceLong("CountStr"+a,b)
 s=""
 For c=0 To b-1:s+GetGadgetItemText(a,c)+Chr(1)
Next:WritePreferenceString("Stringes"+a,s):Next
ClosePreferences()
CloseHandle_(hMutex)
End

fin:
s=GetGadgetText(2)
SetFocus_(gad(0));激活Handle才工作
; SendMessage_(gad(0),#EM_SETSEL, 0, -1)
; SendMessage_(gad(0),#EM_REPLACESEL,0,s)
SendMessage_(gad(0),#WM_SETTEXT, 0, @s)
If s<>"":history(2):Else:Goto re:EndIf
;SendMessage_(gad(eg),#WM_LBUTTONDOWN,0,0):Delay(122)
;SendMessage_(gad(eg),#WM_LBUTTONUP,0,0)
SendMessage_(gad(eg),#BM_CLICK ,0,0)
Return
Last edited by gurj on Sat Mar 02, 2019 10:32 pm, edited 2 times in total.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

@Bisonte:
FindReplaceForPUB.7z [32kb]
rightClick it to choice menu "save as..." to download.
"save as..." is with "&K"
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

please change
EndSelect:ForEver
to
Case #WM_NCLBUTTONDBLCLK
SetWindowPos_(Handle,#HWND_TOP,cx,cy,0,0,#SWP_NOSIZE)
SetWindowPos_(win1,#HWND_TOP,cx,cy,r\right,r\bottom,#SWP_SHOWWINDOW)
While WindowEvent():Wend
EndSelect:ForEver
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

after open the tool, if IDE is mini has question:
IDE and the tool cannot Together.
please Shift+Enter to close tool.
IDE not use mini.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

post updated, all ok!
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: ok: tool for pb IDE's FindReplace bug.

Post by gurj »

red post updated.
my pb for chinese:
http://ataorj.ys168.com
Post Reply