i'm using the TTMSFMXMemo to display lyrics in a karaoke app for macOS.
To highligh the words to be sung i'm using .SelStart and .SelLength.
To get the values for SelStart so that the selection always begins at the start of a line i do the following:
setLength(LyricsLineLength, MyMemo.Lines.Count +1);
LyricsLineLength[0] := 0;
CharCnt := 0;
for i := 1 to MyMemo.Lines.Count -1
do begin
tmpString := MyMemo.Lines[i -1];
CharCnt := CharCnt + length(tmpString) + 2; // for #13#10
LyricsLineLength := CharCnt;
end;
LyricsLineLength[0] := 0;
CharCnt := 0;
for i := 1 to MyMemo.Lines.Count -1
do begin
tmpString := MyMemo.Lines[i -1];
CharCnt := CharCnt + length(tmpString) + 2; // for #13#10
LyricsLineLength := CharCnt;
end;
then do the highlight with
MyMemo.TopLine := tFirstVisibleLine;
MyMemo.SelStart := LyricsLineLength[tCurrentLine];
MyMemo.SelLength := SrtCount;
MyMemo.SelStart := LyricsLineLength[tCurrentLine];
MyMemo.SelLength := SrtCount;
All
works as it should, except for some files (lyrics) where the value for
LyricsLineLength[CurrentLine] is eg. 2461, but MyMemo.SelStart resets to
0.
What can be the reason for SelStart to not accept the value of 2461 ?
Thanks
Victor