05-12-2006, 09:25 AM
I was looking for a function that worked with any editbox...
case 5 works
case 6 crash
case 5 works
case 6 crash
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
def EN_LINK 0x070b
def ENM_LINK 0x04000000
def CFM_COLOR 0x40000000
def CFM_BACKCOLOR 0x4000000
def CFE_BOLD 0x1
def CFM_BOLD 0x1
def CFM_LINK 0x20
def CFE_LINK 0x00000020
def SCF_SELECTION 1
def SCF_WORD 0x2
def SCF_ALL 0x4
def FR_DOWN 0x1
type CHARFORMAT2 cbSize dwMask dwEffects yHeight yOffset crTextColor !bCharSet !bPitchAndFamily !szFaceName[LF_FACESIZE] @wWeight @sSpacing crBackColor lcid dwReserved @sStyle @wKerning !bUnderlineType !bAnimation !bRevAuthor !bReserved1
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 201 56 "BuscaEditBox"
;1 Button 0x54030001 0x4 126 42 32 10 "OK"
;2 Button 0x54030000 0x4 162 42 32 10 "Cancel"
;3 Edit 0x54030080 0x200 6 6 172 12 ""
;4 Button 0x54032000 0x0 180 6 18 12 "RX"
;5 Button 0x54032001 0x0 64 22 66 14 "Buscar/siguiente"
;6 Button 0x54032000 0x0 150 22 48 14 "Buscar todo"
;END DIALOG
;DIALOG EDITOR: "" 0x2010804 "" ""
str controls = "3"
str e3
int+ i2(0) g_newsearch(0) h=child
;mes h
if(!ShowDialog("findeditbox3" &findeditbox3 &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); act id(3 hDlg);mov 5 0.5 hDlg;ont hDlg;ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5
,str rx.getwintext(id(3 hDlg))
,
,int flags=1 ;;1 insens, 2 whole word
,int i length
,;int+ g_newsearch
,str s.getwintext(h); if(!s.len) ret ;;get all text
,if(!g_newsearch)
,,SendMessage(h EM_GETSEL 0 &i) ;;get caret pos
,,i+i2
,i=findrx(s rx i flags|8 length)
,if(i<0) g_newsearch=1; mes- "No se encuentra." "Fin"
,g_newsearch=0
,_s.getwinclass(h)
,if(find(_s "Rich")>=0)
,,_s.get(s 0 i)
,,;out _s
,,;out i
,,ARRAY(str) b
,,int ii=findrx(_s "\r\n" 0 4 b)
,,;escribir_toolbar(ii)
,,i-ii
,,i2+1
,SendMessage(h EM_SETSEL i i+length)
,SendMessage(h EM_SCROLLCARET 0 0)
,
,case 6
,rx.getwintext(id(3 hDlg))
,int found re=h
,CHARRANGE cr
,CHARFORMAT2 cf.cbSize=sizeof(CHARFORMAT2)
,TEXTRANGE editfind
,editfind.chrg.cpMin=0
,editfind.chrg.cpMax=-1
,editfind.lpstrText=rx
,cf.dwMask=CFM_COLOR|CFM_BACKCOLOR|CFM_BOLD
,cf.dwEffects=CFE_BOLD
,cf.crTextColor=ColorFromRGB(255 0 0);; rojo
,cf.crBackColor=ColorFromRGB(255 255 128);; amarillo
,SendMessage(re EM_SETSEL 0 0)
,rep
,,found=SendMessage(share(re) EM_FINDTEXT FR_DOWN &editfind)
,,if(found=-1) break
,,editfind.chrg.cpMin=found+1
,,SendMessage(re EM_SETSEL found found+len(editfind.lpstrText))
,,SendMessage(re EM_SETCHARFORMAT SCF_SELECTION &cf)
,
,case 4
,RegExpMenu id(3 hDlg)
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1