Z,
Here is the algo out of QE that does work selection.
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
select_word proc edit:DWORD
LOCAL ln :DWORD
LOCAL ll :DWORD
LOCAL ci :DWORD
LOCAL os :DWORD
LOCAL mn :DWORD
LOCAL mx :DWORD
LOCAL cr :CHARRANGE
LOCAL cn :CHARRANGE
LOCAL buf[4096]:BYTE
LOCAL pbuf :DWORD
;;;; invoke SleepEx,100,0
invoke SendMessage,edit,WM_KEYDOWN,VK_LEFT,0
invoke SendMessage,edit,EM_EXGETSEL,0,ADDR cr ; get current selection
mov eax, cr.cpMin
mov mn, eax
mov ln, rv(SendMessage,edit,EM_EXLINEFROMCHAR,0,cr.cpMin) ; zero-based index of the line
mov ll, rv(SendMessage,edit,EM_LINELENGTH,cr.cpMin,0) ; get the line length
mov ci, rv(SendMessage,edit,EM_LINEINDEX,ln,0) ; get 1st char offset from beginning
mov eax, cr.cpMin ; offset on line of current caret location
sub eax, ci
mov os, eax
mov eax, ci
mov cr.cpMin, eax
add eax, ll
mov cr.cpMax, eax
invoke SendMessage,edit,EM_HIDESELECTION,1,0
invoke SendMessage,edit,EM_EXSETSEL,0,ADDR cr ; set selection
invoke SendMessage,edit,EM_GETSELTEXT,0,ADDR buf ; get selected text
xor ecx, ecx ; zero ECX + EDX
xor edx, edx
push esi
lea esi, buf ; load buffer address
add esi, os ; add offset to ESI
lbl0:
movzx eax, BYTE PTR [esi] ; scan backwards
cmp BYTE PTR [chtbl+eax], 1 ; testing if acceptable character
jne lbl1
add ecx, 1 ; count characters read backwards
sub esi, 1
jmp lbl0
lbl1:
add esi, 1 ; correct for last char being non acceptable
lbl2:
movzx eax, BYTE PTR [esi] ; scan forwards until next unacceptable character
cmp BYTE PTR [chtbl+eax], 1
jne lbl3
add edx, 1 ; count characters read forward
add esi, 1
jmp lbl2
lbl3:
pop esi
sub ecx, 1
sub mn, ecx
mov eax, mn
mov cr.cpMin, eax
mov cr.cpMax, eax
add cr.cpMax, edx
; |||||||||||||||||||||||||||||||||||||||||||
; zero the selection to the first cpMin value
; |||||||||||||||||||||||||||||||||||||||||||
add eax, edx
mov cn.cpMin, eax
mov cn.cpMax, eax
invoke SendMessage,edit,EM_EXSETSEL,0,ADDR cn
; |||||||||||||||||||||||||||||||||||||||||||
invoke SendMessage,edit,EM_HIDESELECTION,0,0
invoke SendMessage,edit,EM_EXSETSEL,0,ADDR cr ; set selection
quit:
xor eax, eax
ret
align 16
chtbl:
; -----------------------------------------
; upper and lower case, numbers and "_" "." "$"
; -----------------------------------------
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0
db 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1
db 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
; ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤
select_word endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
It is called from here.
case WM_KEYDOWN
switch wParam
case VK_F1
invoke SendMessage,hEdit,EM_EXGETSEL,0,ADDR cr
mov eax, cr.cpMax
sub eax, cr.cpMin
.if eax > 256
fn MessageBox,hWnd,"Selection is too large","Sorry ....",MB_OK
ret
.endif
invoke select_word,hWin
invoke SendMessage,hEdit,EM_EXGETSEL,0,ADDR cr
mov eax, cr.cpMin
.if eax != cr.cpMax ; if the algo selects a word
mov pbuf, ptr$(buffer)
invoke SendMessage,hEdit,EM_GETSELTEXT,0,pbuf
mov pMem, ptr$(buf)
invoke get_app_path,pMem
mov pMem, cat$(pMem,"qehlp.bin")
.if rv(exist,pMem)
mov hMem, InputFile(pMem)
invoke SetWindowText,rv(GetDlgItem,hWin,101),hMem
invoke WinHelp,hWnd,hMem,HELP_PARTIALKEY,pbuf
free hMem
.endif
xor eax, eax
ret
.endif
endsw