How do you get the row and column number in a rich edit?
Posted on 2001-07-23 15:58:24 by ChimpFace9000
Here is the way I did it. chrg refers to a CHARRANGE struct.
I called it in response to the EN_SELCHANGE message.
It puts the current cursor position in a statusbar in the form
of L:1 C:1

Cursor_Position proc

LOCAL Buffer[7]:BYTE
LOCAL StatusText[17]:BYTE

;Get Line Number
invoke SendMessage,hRichEdit,EM_LINEFROMCHAR,-1,0
;Change first line number from 0 to 1
inc eax
mov ecx,eax
;Convert to ascii
invoke dwtoa,ecx,addr Buffer
;First part of display string
mov dword ptr,003A4Ch
invoke lstrcat,addr StatusText,addr Buffer
invoke lstrlen,addr StatusText
mov dword ptr,003A4320h
;Get Column Number
invoke SendMessage,hRichEdit,EM_EXGETSEL,0,addr chrg
invoke SendMessage,hRichEdit,EM_LINEINDEX,-1,0
sub chrg.cpMin,eax
;Change first column number 0 to 1
add chrg.cpMin,1
;Convert to ascii
invoke dwtoa,chrg.cpMin,addr Buffer
;Last part of display string
invoke lstrcat,addr StatusText,addr Buffer
;Display string in StatusBar
invoke SendMessage,hStatusBar,SB_SETTEXT,0,addr StatusText

Cursor_Position endp

Hope this helps.
Posted on 2001-07-23 21:06:48 by anon
Could you edit your post and put it in code tags please. Thanks by the way.
Posted on 2001-07-24 00:22:22 by ChimpFace9000