Author Topic: Perfectlly working FindText routine  (Read 1108 times)

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Perfectlly working FindText routine
« on: November 07, 2021, 08:04:58 AM »
    Here it is:
Code: [Select]
.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:
« Last Edit: November 08, 2021, 06:17:49 AM by xandaz »

mikeburr

  • Member
  • **
  • Posts: 189
Re: Perfectlly working FindText routine
« Reply #1 on: November 07, 2021, 12:25:25 PM »
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

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: Perfectlly working FindText routine
« Reply #2 on: November 07, 2021, 07:40:21 PM »
   yeah. missed that. you're right

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Perfectlly working FindText routine
« Reply #3 on: November 07, 2021, 09:00:54 PM »
The ASSUME is not needed at all. In general, it just obfuscates code and should be avoided.
Code: [Select]
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

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: Perfectlly working FindText routine
« Reply #4 on: November 07, 2021, 09:22:53 PM »
   Surelly. Nice!

mikeburr

  • Member
  • **
  • Posts: 189
Re: Perfectlly working FindText routine
« Reply #5 on: December 02, 2021, 02:56:25 AM »
@JJ
totally agree about ASSUME JJ .. also its not compatible with "similar" compilers
regards mike b