List of Hyperlink

General TRichView support forum. Please post your questions here
Sergey Tkachenko
Site Admin
Posts: 17281
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, as I said in the previous post, the modified code inserts not all links, so they are mismatched.

The solution: when adding links to the list (in RichView1), do not add the link targets as tags. Use the link index instead.

The code below is for the latest version of TRichView, where tags are strings.
For older versions, remove StrToInt and IntToStr, and exclude rvoTagsArePChars from RichView1.Options.

Code: Select all

procedure TFmain.EnumLinksProc(RVData: TCustomRVData; ItemNo: Integer;
  var UserData1: Integer; const UserData2: String;
  var ContinueEnum: Boolean);
var StyleNo: Integer; 
begin 
  StyleNo := RVData.GetItemStyle(ItemNo); 
  if RVData.GetRVStyle.TextStyles[StyleNo].Jump and 
     (RVData.GetRVStyle.TextStyles[StyleNo].Color =  clGreen) then 
    RichView1.AddNLTag(RVData.GetItemText(ItemNo), RVData.GetItemStyle(ItemNo),
      0, IntToStr(UserData1));
  if RVData.GetItem(ItemNo).GetBoolValueEx(rvbpJump, RVData.GetRVStyle) then
    inc(UserData1);
  ContinueEnum := True; 
end;
Now, we need to modify RichView1.OnJump and OnItemHint:

Code: Select all

procedure TFmain.RichView1Jump(Sender: TObject; id: Integer);
var RVData: TCustomRVFormattedData;
    ItemNo: Integer;
begin
  RichView1.GetJumpPointLocation(id, RVData, ItemNo);
  id := StrToInt(RVData.GetItemTag(ItemNo));
  // here, id = link index in RichViewEdit
  RichViewEdit1.GetJumpPointLocation(id, RVData, ItemNo);
  RVData := TCustomRVFormattedData(RVData.Edit);
  RVData.SetSelectionBounds(ItemNo, RVData.GetOffsBeforeItem(ItemNo),
    ItemNo, RVData.GetOffsAfterItem(ItemNo));
  RichViewEdit1.SetFocus;
end;

Code: Select all

procedure TFmain.RichView1ItemHint(Sender: TCustomRichView;
  RVData: TCustomRVData; ItemNo: Integer; var HintText: String);
var id, LItemNo: Integer;
    LRVData: TCustomRVFormattedData;
begin
  if RVData.GetItem(ItemNo).GetBoolValueEx(rvbpJump, RVData.GetRVStyle) then begin
    id := StrToInt(RVData.GetItemTag(ItemNo));
    // here, id = link index in RichViewEdit
    RichViewEdit1.GetJumpPointLocation(id, LRVData, LItemNo);
    HintText := LRVData.GetItemTag(LItemNo);
  end;
end;
miwan
Posts: 26
Joined: Tue Nov 01, 2011 8:30 pm

Post by miwan »

Ok beautiful
that's really what I wanted
problem solved

excuse me for taking too much of your time

thank you very much :D
Post Reply