> > 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 > using? >
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); var selbegin,sellen:integer; begin selbegin:=RichMemo1.SelStart; RichMemo1.PasteFromClipboard; sellen:=RichMemo1.SelStart-selbegin; RichMemo1.SetRangeColor(selbegin,sellen,clred); end; 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. Ludo -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
