How to set cursor at the end of document ?

General TRichView support forum. Please post your questions here
Post Reply
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

How to set cursor at the end of document ?

Post by Marsianin »

I want to implement 'entire scope' search (which is not implemented for RichViewEdit) and need to set cursor to the end of the document when direction is UP.

I'm using RVSetLinearCaretPos but don't know how to get the last symbol position number.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

rve.SetSelectionBounds(rve.ItemCount-1, rve.GetOffsAfterItem(rve.ItemCount-1), rve.ItemCount-1, rve.GetOffsAfterItem(rve.ItemCount-1))
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

And how to use it ?

And how to get the last character number in the text ? Will it be rve.ItemCount-1 ?
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

Just read the help :)

Code: Select all

var
  ItemNo, Offs: Integer;
...
ItemNo := MyRichViewEdit.ItemCount-1;
Offs   := MyRichViewEdit.GetOffsAfterItem(ItemNo);
MyRichViewEdit.SetSelectionBounds(ItemNo,Offs,ItemNo,Offs);
Same code as you posted above. Thanks.
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

But another one question.
Is there a way to perform search in all document without changing position of the caret ?
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What do you mean by "without changing position of the caret"? Not changed if nothing is found, or not changing at all?
May be you are searching for something like this:
http://www.trichview.com/forums/viewtopic.php?t=57
recbeat
Posts: 2
Joined: Mon Jul 23, 2007 1:18 pm

Could not make this work

Post by recbeat »

Hello,



I tried the code you suggested but to no avail. I got 'List index out of bounds (-1)' error. I added one item into RichView to test this in order to add text to the end of the document:
var
ItemNo, Offs: Integer;
...
ItemNo := MyRichViewEdit.ItemCount-1;
Offs := MyRichViewEdit.GetOffsAfterItem(ItemNo);
MyRichViewEdit.SetSelectionBounds(ItemNo,Offs,ItemNo,Offs);
What is wrong? I'm trying this on Delphi 7.

Thanks for any help.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be your RichViewEdit was not formatted?
recbeat
Posts: 2
Joined: Mon Jul 23, 2007 1:18 pm

Post by recbeat »

Hello Sergey,



Yes, the 'Format' call figured this out. Thanks!
Post Reply