unit Unit1;

interface

{==============================================================================}
{ This demo show how to use information about hypertext item.                  }
{------------------------------------------------------------------------------}
{ Key methods:                                                                 }
{ - GetJumpPointLocation;                                                      }
{ - methods for obtaining information about items (see first demo in this      }
{   group.                                                                     }
{ Useful if text is self-describing (for example, for WWW addresses).          }
{==============================================================================}

{$I RV_Defs.inc}

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ImgList,
  RVStyle, ExtCtrls, RVScroll, RichView, StdCtrls, CRVFData;

type
  TForm1 = class(TForm)
    RichView1: TRichView;
    Panel1: TPanel;
    RVStyle1: TRVStyle;
    ImageList1: TImageList;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure RichView1Jump(Sender: TObject; id: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var ico: TIcon;
begin
  RichView1.AddNL('Hypertext',1,1);
  RichView1.AddNL('Some text styles can be chosen as hypertext styles. ',0,0);
  RichView1.Add('Like this one.',4);
  RichView1.Add(' You can have as many hypertext styles as you want.  ',0);
  RichView1.Add('Here is one more.',5);
  RichView1.AddNL('Images from Image Lists also can be hypertext: ',0,0);
  RichView1.AddHotspotEx('Pen Image', 0,1, ImageList1, -1);
  RichView1.Add(' Such images are called "hotspots".',0);
  RichView1.AddNL('Normal images also can be hypertext: ',0,0);
  ico := TIcon.Create;
  ico.Assign(Image1.Picture.Graphic);
  RichView1.AddHotPicture('Bobo', ico, -1, rvvaBaseLine);

  RichView1.Format;
end;

procedure TForm1.RichView1Jump(Sender: TObject; id: Integer);
var RVData: TCustomRVFormattedData;
    ItemNo: Integer;
begin
  RichView1.GetJumpPointLocation(id, RVData, ItemNo);
  Panel1.Caption := 'Clicked: '+RVData.GetItemText(ItemNo);
end;

end.