Hi all,
1. How to higlight whole line, like Ultra Edit. (when you press up & down key it also move)
2. How to select whole line.

Thanks
Posted on 2003-11-29 08:19:57 by QS_Ong
I assume you're talking about Edit controls. The code might work for richedit, too.




SelectWholeLine proc hWnd
local heap1,str1,selStart,selEnd
;--- get text -- --------\
invoke GetProcessHeap
mov heap1,eax
invoke HeapAlloc,eax,HEAP_ZERO_MEMORY,65536
mov str1,eax
or eax,eax
jz _ret
invoke GetWindowText,hWnd,str1,65535
invoke SendMessage,hWnd,EM_GETSEL,addr selStart,0
;-----------------------/
;---- find line start -------\
mov ebx,str1
mov ecx,selStart
push ecx
_again01:
or ecx,ecx
jz _done02
mov al,[ebx+ecx]
cmp al,13
je _done01
cmp al,10
je _done01
dec ecx
jmp _again01
_done01:
inc ecx
_done02:
mov selStart,ecx
;----------------------------/
;---- find line end -----\
pop ecx
@@:
mov al,[ebx+ecx]
or al,al
jz @F
cmp al,13
jz @F
inc ecx
jmp @B
@@:
dec ecx
mov selEnd,ecx
;------------------------/
;---- set selection --\
invoke SendMessage,hWnd,EM_SETSEL,selStart,selEnd
invoke HeapFree,heap1,0,str1
;---------------------/
_ret: ret
SelectWholeLine endp
Posted on 2003-11-29 10:26:16 by Ultrano