How can I get SelStart?

General TRichView support forum. Please post your questions here
Post Reply
Ilya Shalnov
Posts: 10
Joined: Sat Oct 02, 2021 6:43 pm

How can I get SelStart?

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How can I get SelStart?

Post 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)
Ilya Shalnov
Posts: 10
Joined: Sat Oct 02, 2021 6:43 pm

Re: How can I get SelStart?

Post by Ilya Shalnov »

Thank you, it works now!
Post Reply