Author Topic: EM_EXSETSEL problem...  (Read 23741 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: EM_EXSETSEL problem...
« Reply #30 on: September 24, 2012, 02:05:08 AM »

To see them you need to have, a long horizontal text to view the horizontal scrool bar and many lines to see the vertical scrooll bar.If not needed,not shown.
Fa is a musical note to play with CL

PsYcHoCoDe

  • Guest
Re: EM_EXSETSEL problem...
« Reply #31 on: September 24, 2012, 02:09:42 AM »
yes, mate, i got them... want to think of some way to do it actually automatically scroll down to the found string's line, u know... so that i can think figure out how my algo should go further...

P.S: anyway, i stillg have to develop/extend the search algorithm, etc further... that was just the 'basic' stuff... thank u very much for the help, guys!  :t

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: EM_EXSETSEL problem...
« Reply #32 on: September 24, 2012, 02:20:11 AM »
Quote
want to think of some way to do it actually automatically scroll down
Study a help file,you will find a fonction who allow to show the found line at the desired position on the screen.UP screen to down screen.The code isn't to easy to write.Result depend of the screen resolution.

Fa is a musical note to play with CL

PsYcHoCoDe

  • Guest
Re: EM_EXSETSEL problem...
« Reply #33 on: September 24, 2012, 02:21:43 AM »
screen resolution dependency would be quite a problem about that...  :redface:

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: EM_EXSETSEL problem...
« Reply #34 on: September 24, 2012, 02:43:22 AM »

The difference with various screen resolution isn't very important but he is.
The line could appear one line upper or down than you want,that all.
The midle position on the screen is the better for me.
Fa is a musical note to play with CL

PsYcHoCoDe

  • Guest
Re: EM_EXSETSEL problem...
« Reply #35 on: September 24, 2012, 02:46:50 AM »
@ ToutEnMasm : thanks, mate, i'll keep that in mind while developing this... the middle position's actually kinda better for the application actually  :t

jj2007

  • Member
  • *****
  • Posts: 12298
  • Assembler is fun ;-)
    • MasmBasic
Re: EM_EXSETSEL problem...
« Reply #36 on: September 24, 2012, 02:54:37 AM »
P.S.: btw what riched window message could i use to scroll it down to the found position?

Something like this should do the job:
Code: [Select]
xor edi, edi
.Repeat
invoke SendMessage, hRE, EM_GETFIRSTVISIBLELINE, 0, 0
sub eax, esi  ; compare to some desired line count
.Break .if !Sign?
invoke SendMessage, hRE, EM_SCROLL, SB_LINEDOWN, 0
inc edi
.Until edi>99 ; break if limit exceeded (e.g. bottom of doc)

SetFocus is not required. RichMasm sets the selection while the user scrolls down the listbox showing the search results, so obviously the listbox has the focus.

PsYcHoCoDe

  • Guest
Re: EM_EXSETSEL problem...
« Reply #37 on: September 24, 2012, 04:04:16 AM »
@ jj2007 : thank u, mate, i'll checkit out right away in the morning and i'll report...  :t

PsYcHoCoDe

  • Guest
Re: EM_EXSETSEL problem...
« Reply #38 on: September 25, 2012, 01:47:45 AM »
@ jj2007 : well, i finally ended up with an algo to calculate new lines from the start and just use EM_LINESCROLL to set the 'current' line...  8) btw is there a 'trustworthy way' to get on which line is actually placed the currently marked up selection? sinds the custom algo tends to have some... erm... bug actually :P what i mean is basically i.e. : get the index with EM_EXGETSEL and eventually using some message to get the actual line number, @which the selection is?

jj2007

  • Member
  • *****
  • Posts: 12298
  • Assembler is fun ;-)
    • MasmBasic
Re: EM_EXSETSEL problem...
« Reply #39 on: September 25, 2012, 03:54:47 AM »
btw is there a 'trustworthy way' to get on which line is actually placed the currently marked up selection?

Sure, it's EM_EXLINEFROMCHAR

PsYcHoCoDe

  • Guest
Re: EM_EXSETSEL problem...
« Reply #40 on: September 25, 2012, 05:01:55 AM »
@ jj2007 : it's kinda strange, but the offset that does the EM_EXLINEFROMCHAR tends to be kinda pretty the same, as the home brew algo... seems like i'll have to look fer sth somewhere earlier as a defect... :/ the buffer's like 32 BYTES long string (CR - converted to 'C' (if ain't terminators of a 32 bytes string len), LF - converted to 'L' (again, if they're not secondary terminators), zeroes - replaced with SPACE (020h))... each line's fixed len 32 bytes long...  :icon_eek:

P.S.: While the actual selection using EM_EXSETSEL's perfectly correct...  somehow it offsets some quite lines PAST each iteration... though the first (find first actually' correct)

PsYcHoCoDe

  • Guest
Re: EM_EXSETSEL problem...
« Reply #41 on: September 25, 2012, 05:16:21 AM »
here's the actual code... both the initial variant, the secondary variant of an algo (the initial's actually kinda stupid, cuz i thought to do it another way, whatever...) and the EX_LINEFROMCHAR option...

Quote
COMMENT %
GetLineCountToFoundString PROC uses ecx esi edi edx dwInitRVA:DWORD, dwRVA:DWORD ; returns ZeroBased index...
    xor ecx, ecx ; line count
    xor edx, edx ; byte count
    mov esi, dwInitRVA
    mov edi, dwRVA
@count_lpy:
    cmp esi, edi
    jge @out_of_loop
    lodsb
    inc edx
    cmp edx, 32
    jz @go_count_line
    jmp @count_lpy
@go_count_line:
    cmp word ptr [esi], 0A0Dh
    jz @fix_esi
    xor edx, edx
    inc edx
    inc esi
    inc ecx
    jmp @count_lpy
@fix_esi:
    add esi, 02h
    inc ecx
    xor edx, edx
    jmp @count_lpy
@out_of_loop:
    xchg eax, ecx
    ret
GetLineCountToFoundString ENDP
%

GetLineCountToFoundString PROC uses ecx esi edi dwBaseRVA:DWORD, dwTargRVA:DWORD
    xor ecx, ecx
    mov esi, dwBaseRVA
    mov edi, dwTargRVA
@calc_lpy:
    add esi, 32
    cmp word ptr [esi], 0A0Dh
    jz @count_CRLF
    inc ecx
@check_if_done:
    cmp esi, edi
    jge @out_of_loop
    jmp @calc_lpy
@count_CRLF:
    add esi, 02h
    inc ecx
    jmp @check_if_done
@out_of_loop:
    xchg eax, ecx
    dec eax
    ret
GetLineCountToFoundString ENDP

FindNextString PROC
LOCAL currChar:CHARRANGE
LOCAL fdText:FINDTEXT
LOCAL scrLines:DWORD
LOCAL lenSz:DWORD
int 3
    lea edi, currChar
    xor eax, eax
    mov ecx, sizeof currChar/04h
    rep stosd
   
    invoke szLen, addr srchString
    mov lenSz, eax
   
    invoke SendDlgItemMessage, hWnd, ID_CTEXT, EM_EXGETSEL, 0, addr currChar
    lea ebx, fdText
ASSUME EBX:PTR FINDTEXT
    mov eax, currChar.cpMin
    add eax, lenSz
    mov [ebx].chrg.cpMin, eax
    mov eax, -1
    mov [ebx].chrg.cpMax, eax
    lea eax, srchString
    mov [ebx].lpstrText, eax
    invoke SendDlgItemMessage, hWnd, ID_CTEXT, EM_FINDTEXT, FR_DOWN, addr fdText
    cmp eax, 0FFFFFFFFh
    jz @not_found
    mov [ebx].chrg.cpMin, eax
    mov [ebx].chrg.cpMax, eax
    mov eax, lenSz
    add [ebx].chrg.cpMax, eax
    invoke SendDlgItemMessage, hWnd, ID_CTEXT, EM_EXSETSEL, 0, addr [ebx].chrg

    invoke SendDlgItemMessage, hWnd, ID_CTEXT, EM_EXLINEFROMCHAR, 0, [ebx].chrg.cpMin
    mov scrLines, eax

    ;mov ecx, txtAddr
    ;mov eax, [ebx].chrg.cpMin
    ;add eax, ecx
    ;invoke GetLineCountToFoundString, ecx, eax
    ;mov scrLines, eax
   
    invoke SendDlgItemMessage, hWnd, ID_CTEXT, EM_LINESCROLL, 0, scrLines
ASSUME EBX:PTR NOTHING
    ret
@not_found:
    xor eax, eax
    ret
FindNextString ENDP