trichview.com Forum Index trichview.com
TRichView support forums
 

[Unit] Moving to the next/previous item


 
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos
    View previous topic :: View next topic  
Author Message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 10717

PostPosted: Sat May 02, 2009 4:33 pm    Post subject: [Unit] Moving to the next/previous item Reply with quote

http://www.trichview.com/support/files/gotoitem.zip

GoToItem.pas includes functions for moving the caret to the next/previous item meeting the specified criteria. The caret is moved to the end of the found item (the item can be selected optionally).
The functions return True if moving was successful (False if the item was not found in the given direction). The search is started from the current item (i.e. the item containing the caret).

Moving the caret to the next/previous hyperlink:
function GoToNextHyperlink(rve: TCustomRichViewEdit; Select: Boolean=False): Boolean;
function GoToPrevHyperlink(rve: TCustomRichViewEdit; Select: Boolean=False): Boolean;

Moving the caret to the next/previous item of one of the specified types:
function GoToNextItem(rve: TCustomRichViewEdit; ItemTypes: array of Integer; Select: Boolean=False): Boolean;
function GoToPrevItem(rve: TCustomRichViewEdit; ItemTypes: array of Integer; Select: Boolean=False): Boolean;
Example (moving to the next picture):
Code:
GoToNextItem(rve, [rvsPicture, rvsHotPicture])


Moving the caret to the next/previous item, using a user-defined function for checking items:
function GoToNextItemEx(rve: TCustomRichViewEdit; UserData: Pointer; Func: TCheckItemFunction; Select: Boolean=False): Boolean;
function GoToPrevItemEx(rve: TCustomRichViewEdit; UserData: Pointer; Func: TCheckItemFunction; Select: Boolean=False): Boolean;
UserData parameter is passed to Func.
Func is a function for checking items. It must return True if RVData.GetItem(ItemNo) is ok (i.e. the caret should be moved to it).
type TCheckItemFunction = function (RVData: TCustomRVData; ItemNo: Integer; UserData: Pointer): Boolean;
Example (moving to the next text having a colored background):
Code:
function IsColoredText(RVData: TCustomRVData; ItemNo: Integer;
    UserData: Pointer): Boolean;
var StyleNo: Integer;
begin
  StyleNo := RVData.GetItemStyle(ItemNo);
  Result := (StyleNo>=0) and (RVData.GetRVStyle.TextStyles[StyleNo].BackColor<>clNone);
end;
...
  GoToNextItemEx(RichViewEdit1, nil, IsColoredText);
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group