News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Perfectlly working FindText routine

Started by xandaz, November 07, 2021, 08:04:58 AM

Previous topic - Next topic

xandaz

    Here it is: .elseif uMsg==edi ; FINDMSGSTRING
invoke SendMessage,hMdi,WM_MDIGETACTIVE,0,0
invoke GetWindowLong,eax,GWL_USERDATA

mov edi,eax
mov esi,lParam

assume  esi:PTR FINDREPLACE

                xor            ebx,ebx
test [esi.FINDREPLACE].Flags,FR_DIALOGTERM
jnz end_find
      mov ft.chrg.cpMax,-1
push [esi.FINDREPLACE].lpstrFindWhat
pop ft.lpstrText
test [esi].Flags,FR_DOWN
jz skip_1
or ebx,FR_DOWN
skip_1:
test [esi].Flags,FR_MATCHCASE
jz skip_2
or ebx,FR_MATCHCASE
skip_2:
test [esi].Flags,FR_WHOLEWORD
jz skip_3
or ebx,FR_WHOLEWORD
skip_3:
mov crange.cpMin,rv(SendMessage,[edi.MdiStruct.hEdit],EM_FINDTEXTEX,ebx,addr ft)
cmp eax,-1
je end_find_2
push crange.cpMin
pop ft.chrg.cpMin
test [esi].Flags,FR_DOWN
jz skip_4
inc ft.chrg.cpMin
jmp skip_5
skip_4:
dec ft.chrg.cpMin
skip_5:
invoke SendMessage,[edi.MdiStruct.hEdit],EM_EXSETSEL,0,addr ft.chrgText
invoke SendMessage,[edi.MdiStruct.hEdit],EM_HIDESELECTION,FALSE,0
invoke SendMessage,[edi.MdiStruct].hEdit,EM_SCROLLCARET,0,0
jmp end_find_2
end_find:
mov ft.chrg.cpMin,0
mov crange.cpMin,0
mov eax,TRUE
ret
end_find_2:

mikeburr

i think its prob good practice to end the assume ... assume esi:NOTHING as from recollection its easy to get nesting.. 3 Levels ?? of assume then it fails
regards mikeb

xandaz


jj2007

The ASSUME is not needed at all. In general, it just obfuscates code and should be avoided.
push [esi.FINDREPLACE].lpstrFindWhat
pop ft.lpstrText
test [esi.FINDREPLACE].Flags,FR_DOWN
jz skip_1
or ebx,FR_DOWN
skip_1:
test [esi.FINDREPLACE].Flags,FR_MATCHCASE

xandaz


mikeburr

@JJ
totally agree about ASSUME JJ .. also its not compatible with "similar" compilers
regards mike b