Sergey Tkachenko wrote:As for the second question, you need to patch it as well, there is no standard solution (although, we are thinking about adding this functionality in TRichView.SearchText)
Modify MarkSubString_:
Code: Select all
...
if P > 0 then
...
// store RVData.GetSourceRVData and I
end;
...
(important, the code for storing must be at the very end of "if P > 0")
To select StoredRVData and StoredItemNo:
Code: Select all
var RVData: TCustomRVFormattedData;
RVData := TCustomRVFormattedData(StoredRVData.Edit);
RVData.SetSelectionBounds(StoredItemNo, RVData.GetOffsBeforeItem(StoredItemNo), StoredItemNo, RVData.GetOffsAfterItem(StoredItemNo));
I created this Types in MarkSearch.Pas:
Code: Select all
type TMyRVData = record
RVData : TCustomRVFormattedData;
ItemNo : Integer;
end;
type MyRVData = array of TMyRVData;
Then I sent MyRVData to MarkSubStringW and MarkSubString_ functions as variable parameter to store RVData and I in it.
I stored RVData and I in MarkSubString_ like this:
Code: Select all
function MarkSubString_(RVData: TCustomRVData; const s: TRVAnsiString;
const sw: TRVRawByteString; Color, BackColor: TColor;
DelimSet: TSetOfChar; DelimW: PWideChar; DelimWLen: Integer;
Options: TRVMarkStringOptions;[b]var MyStoredRVData : MyRVData[/b]): Integer;
var
...
j : Integer;
begin
Result := 0;
SetLength(MyStoredRVData,RVData.ItemCount);
j := 0;
...
if P > 0 then
begin
...
MyStoredRVData[j].RVData := TCustomRVFormattedData(RVData.GetSourceRVData);
MyStoredRVData[j].ItemNo := i;
j := j + 1;
End;
then in my main unit I called MarkSubStringW:
Code: Select all
var MyRVData2 : MyRvData
FoundItemNo : integer;
...
MarkSubStringW(MySearchText,clred, clYellow,myOptions,RichViewEdit1, MyRVData2);
FoundItemNo := 0;
and in My NextButton OnClick Event I typed:
Code: Select all
var tmpRVData: TCustomRVFormattedData;
StoredItemNo : Integer;
begin
if FoundItemNo <= Length(MyRVData2) - 1 then
begin
StoredItemNo := MyRVData2[FoundItemNo].ItemNo;
tmpRVData := TCustomRVFormattedData(MyRVData2[FoundItemNo].RVData.Edit);
tmpRVData.SetSelectionBounds(StoredItemNo, tmpRVData.GetOffsBeforeItem(StoredItemNo), StoredItemNo, tmpRVData.GetOffsAfterItem(StoredItemNo));
FoundItemNo := FoundItemNo + 1;
end;
and in My PreviousButton OnClick Event I typed:
Code: Select all
var tmpRVData: TCustomRVFormattedData;
StoredItemNo : Integer;
begin
if FoundItemNo >=0 then
begin
StoredItemNo := MyRVData2[FoundItemNo].ItemNo;
tmpRVData := TCustomRVFormattedData(MyRVData2[FoundItemNo].RVData.Edit);
tmpRVData.SetSelectionBounds(StoredItemNo, tmpRVData.GetOffsBeforeItem(StoredItemNo), StoredItemNo, tmpRVData.GetOffsAfterItem(StoredItemNo));
FoundItemNo := FoundItemNo - 1;
end;
but it doesn't work correctly. Please help.