see the follow simple example.
In the example the cursor starting point is behind "u" from the word "jump".
Then I click on the 'btn_SetCursorToStart".
The cursor appear bevor "T".
Then I click on the "btn_ReturnCursor", the cursor appear on the starting point.
So far, so good.
Now, I would change the color to green in the word "quick".
I click on the "btn_SetCursorToStart", "btn_SetWordGreen" and then "btn_ReturnCursor".
It doesn't work.
I do understand the reason, but how can i solve it.
The cursor should be return on the starting point.
Code: Select all
procedure TForm16.FormCreate(Sender: TObject);
var
f: TFontInfo;
begin
RVStyle.TextStyles.Clear;
f := RvStyle.TextStyles.Add;
f.FontName := 'Courier new';
f.Size := 9;
f.StyleName := 'Normal';
f := RvStyle.TextStyles.Add;
f.FontName := 'Courier new';
f.Size := 9;
f.Color := clGreen;
f.StyleName := 'Green';
rv.InsertText('The quick brown fox jumps over the lazy dog');
end;
procedure TForm16.btn_SetCursorToStartClick(Sender: TObject);
begin
FCurItemNo := rv.CurItemNo;
FCurOff := TRVEditRVData(rv.RVData).GetOffsetInCurItem;
rv.SetSelectionBounds(0, 0, 0, 0);
rv.SetFocus;
end;
procedure TForm16.btn_ReturnCursorClick(Sender: TObject);
begin
rv.SetSelectionBounds(FCurItemNo, FCurOff, FCurItemNo, FCurOff);
rv.SetFocus;
end;
procedure TForm16.btn_SetWordGreenClick(Sender: TObject);
begin
rv.SearchText('quick', [rvseoDown]);
rv.ApplyTextStyle(1);
rv.Invalidate;
end;