Page 1 of 1

How can I get SelStart?

Posted: Sun Oct 03, 2021 7:09 am
by Ilya Shalnov
I try to do that this way

uses
... RVLinear;


function SelStart(RVE:TRichViewEdit):integer;
var
SelStart:integer;
SelLength:integer;
int:integer;
begin
RVGetSelection(RVE,SelStart,SelLength,int);
Result:=SelStart;
end;

When it is done with the first line, it works fine. When I go to the second line or to any other line the function returns some very big number.

Re: How can I get SelStart?

Posted: Sun Oct 03, 2021 7:06 pm
by Sergey Tkachenko
The last parameter of RVGetSelection is a number of characters per a line break.
You pass an uninitialized value to the last parameter, so the results RVGetSelection become random for the second and further lines.
Normally, either 1 or 2 are used for this parameter. The default of RVGetSelection is 2.
I recommend to use the default value:
RVGetSelection(RVE,SelStart,SelLength)

Re: How can I get SelStart?

Posted: Sun Oct 03, 2021 10:24 pm
by Ilya Shalnov
Thank you, it works now!