The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on November 30, 2007, 08:34:50 PM

Title: append a line on richedit
Post by: Farabi on November 30, 2007, 08:34:50 PM
How to add a text on rich edit without erasing existing text?
Title: Re: append a line on richedit
Post by: ossama on November 30, 2007, 08:55:14 PM
if you want to insert the text into the end of the text in the rich edit control do this:

..
..
chrg CHARRANGE<>
szNewText db "this is the new text to be inserted",0
..
..
;set the cursor in the end of the rich edit text
mov chrg.cpMin,-1
mov chrg.cpMax,0
invoke SendMessage,hRrichEdit,EM_EXSETSEL,0,addr chrg

;insert nex text
invoke SendMessage,hRrichEdit,EM_REPLACESEL,TRUE,addr szNewText


and if you want to replace any selection in the rich edit text do this:


invoke SendMessage,hRrichEdit,EM_REPLACESEL,TRUE,addr szNewText


and if you want to cancel any selection and insert the text in the currrent position of the cursor do the following :


..
..
mov eax,chrg.cpMax
mov chrg.cpMin,eax
invoke SendMessage,hRrichEdit,EM_EXSETSEL,0,addr chrg
;insert nex text
invoke SendMessage,hRrichEdit,EM_REPLACESEL,TRUE,addr szNewText
..
..

i hope this solve your problem
Title: Re: append a line on richedit
Post by: Farabi on December 01, 2007, 07:15:26 AM
Wow. thanks  :U