Board index » delphi » Adding Strings to TMemo or TRichEdit

Adding Strings to TMemo or TRichEdit

Thanks in advance:
I need to know how to get the cursor position in TMemo and TRichEdit.  I
need this information so that text strings could be added at this position.
 That brings the next question.  How do I insert strings into a TMemo or
TRichEdit at a certain position, (such as the current cursor position).
The Add and Insert methods are not good enough and only allow adding
strings to the end of the memo or inserting at a given line number.

 

Re:Adding Strings to TMemo or TRichEdit


Quote
Andrew Seitz wrote:

> Thanks in advance:
> I need to know how to get the cursor position in TMemo and TRichEdit.  I
> need this information so that text strings could be added at this position.
>  That brings the next question.  How do I insert strings into a TMemo or
> TRichEdit at a certain position, (such as the current cursor position).
> The Add and Insert methods are not good enough and only allow adding
> strings to the end of the memo or inserting at a given line number.

        If you want to insert text at the current cursor position you
can just say SelText= 'whatever'. You might or might not want to set
SelLength:= 0 first, depending on whether you want to replace any text
that may be selected.

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

Re:Adding Strings to TMemo or TRichEdit


Quote
>   "Andrew Seitz" <sei...@docker.com> writes:
>  Thanks in advance:
>  I need to know how to get the cursor position in TMemo and TRichEdit.  I
>  need this information so that text strings could be added at this position.
>   That brings the next question.  How do I insert strings into a TMemo or
>  TRichEdit at a certain position, (such as the current cursor position).
>  The Add and Insert methods are not good enough and only allow adding
>  strings to the end of the memo or inserting at a given line number.

I do not have the detail but I think there are API-routine you can use.
Look at EM_posfromchar for example.

I am not sure - but can't you just add the text by using richedit.seltext := 'whatever',  if you first make sure that sellength := 0. Isn't selstart where the cursor is?

johan

Other Threads