[Lazarus] RE : RE : RE : Displaying text with colour and insertionpoint
ludo.brands at free.fr
Sat May 19 11:52:20 CEST 2012
> The good news is that TRichMemo is a painless replacement for TMemo,
> despite my various hacks and admitted inexperience. However, when I'm
> using SetTextAttributes() or SetRangeColor(), should the position
> parameter be based on the number of bytes or the number of
> characters of
> existing text? I'm having problems getting this right, which
> I suspect
> are due to the high proportion of non-ASCII characters.
> Or put another way, in the simplest case where I want to change the
> colour of the most-recently-added character, what parameters
> should I be
Don't know what function you are using to add the characters but here is a
routine that will paste from the clipboard in red at the cursor position:
procedure TForm1.Button1Click(Sender: TObject);
Tried this on windows by pasting chinese characters with the cursor in the
middle of an existing text: only the pasted characters are colored red.
So the trick is to get the cursor position before and after the insertion
and take these values to define the range, then color that range. Whatever
the characters inserted, single byte or multibyte, the cursor position
reflects this correctly.
More information about the Lazarus