Добрый день.
Что я делаю не так? При нескольких нажатиях мыши по RichEdit при выполнении кода появляется ошибка(прикрепил во вложениях).Такое ощущение, что причиной становится перескакивание каретки при нажатии мыши.
ReadOnly:=true
Код:
procedure TFMain.logAdd(LogText: string; color_log: Integer = 0);
var
xStart: Integer;
TimeLine:string;
begin
TimeLine:='[ ' + TimeToStr(Now) + ' ] ';
with RichEdit do
begin
xStart := Length(StringReplace(Text,#13,'',[rfReplaceAll, rfIgnoreCase]));
Lines.Add(TimeLine + LogText);
SetFocus;
Lines.BeginUpdate;
SelStart := xStart;
SelLength := Length(TimeLine);
SelAttributes.Style := SelAttributes.Style + [fsBold];
case color_log of
0:
SelAttributes.Color := clGreen;
1:
SelAttributes.Color := clWebDarkOrange;
2:
SelAttributes.Color := clRed;
3:
SelAttributes.Color := clWebBrown;
end;
SetFocus;
SelStart := xStart + SelLength;
SelLength := Length(LogText);
SelAttributes.Color := clBlue;
Lines.EndUpdate;
end;
end;