RichEdit SetAttributes.Color ...
Hello
How can I, while working with Richedit, change the colour of certain code
words?
The filtering of a word, already fails when using the function WordAtCursor
(further down),
because lines and commas are not recognised as dividers (can you add a
divider?)
Alternatively I tried to change the complete text to Standard-colour and
afterwards used the command FINDTEXT to find all code words and then using
SelStart, SelLength and
SetAttributes.Color to change the colour of the code words. The result of
this procedure was that the text scrolled and working was impossible. Can
the scrolling be stopped?
Thanks
Function WordAtCursor: string;
var
Range: TCharRange;
begin
Result := '';
if HandleAllocated then begin
Range.cpMax := SelStart;
if Range.cpMax = 0 then Range.cpMin := 0
else if SendMessage(Handle, EM_FINDWORDBREAK, WB_ISDELIMITER,
Range.cpMax) <> 0 then
Range.cpMin := SendMessage(Handle, EM_FINDWORDBREAK, WB_MOVEWORDLEFT,
Range.cpMax)
else
Range.cpMin := SendMessage(Handle, EM_FINDWORDBREAK, WB_LEFT,
Range.cpMax);
while SendMessage(Handle, EM_FINDWORDBREAK, WB_ISDELIMITER, Range.cpMin)
<> 0 do
Inc(Range.cpMin);
Range.cpMax := SendMessage(Handle, EM_FINDWORDBREAK, WB_RIGHTBREAK,
Range.cpMax);
Result := Trim(GetTextRange(Range.cpMin, Range.cpMax));
end;
end;