HTML Buttons

General TRichView support forum. Please post your questions here
Post Reply
worksmart
Posts: 16
Joined: Thu Jul 06, 2006 8:27 am

HTML Buttons

Post by worksmart »

Hi

Is it possble to load a html page with buttons and re-act when the buttons are clicked.

Thanks

Mike
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I am afraid it would be difficult to do, RVHtmlImport does not support buttons. And that code do you want to execute on clicking, JavaScript?
worksmart
Posts: 16
Joined: Thu Jul 06, 2006 8:27 am

Post by worksmart »

I What would be great is the buttons in html becoming hotspots in the conversion so that the richview control can pickup which button is being pressed. I.e convert button click into standard richivew action which the application can control
worksmart
Posts: 16
Joined: Thu Jul 06, 2006 8:27 am

Post by worksmart »

On a different note

Can the html convserion cope with url link?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Include rvoTagsArePChars in TRichView.Options. By default, HtmlImporter writes hyperlink targets in item tags.
A complete code working with hyperlinks in tags includes processing of 3 events: OnJump, OnReadHyperlink, OnWriteHyperlink. Just copy this code in your application:

Code: Select all

uses CRVData, CRVFData, ShellApi;

procedure TForm3.RichViewEdit1Jump(Sender: TObject; id: Integer);
var ItemNo: Integer;
    RVData: TCustomRVFormattedData;
    s: String;
begin
  RichViewEdit1.GetJumpPointLocation(id, RVData, ItemNo);
  s := PChar(RVData.GetItemTag(ItemNo));
  ShellExecute(0, 'open', PChar(s), nil, nil, SW_SHOW);
end;

procedure TForm3.RichViewEdit1ReadHyperlink(Sender: TCustomRichView;
  const Target, Extras: String; DocFormat: TRVLoadFormat; var StyleNo,
  ItemTag: Integer; var ItemName: String);
begin
    ItemTag := Integer(StrNew(PChar(Target)));
end;

procedure TForm3.RichViewEdit1WriteHyperlink(Sender: TCustomRichView;
  id: Integer; RVData: TCustomRVData; ItemNo: Integer;
  SaveFormat: TRVSaveFormat; var Target, Extras: String);
begin
  Target := PChar(RVData.GetItemTag(ItemNo));
end;
---

Update 2011-Oct-22: for TRichView 13.3+, the code must be:

Code: Select all

uses CRVData, CRVFData, ShellApi;

procedure TForm3.RichViewEdit1Jump(Sender: TObject; id: Integer);
var ItemNo: Integer;
    RVData: TCustomRVFormattedData;
    s: String;
begin
  RichViewEdit1.GetJumpPointLocation(id, RVData, ItemNo);
  s := RVData.GetItemTag(ItemNo);
  ShellExecute(0, 'open', PChar(s), nil, nil, SW_SHOW);
end;

procedure TForm3.RichViewEdit1ReadHyperlink(Sender: TCustomRichView;
  const Target, Extras: String; DocFormat: TRVLoadFormat; var StyleNo: Integer;
  var ItemTag: TRVTag; var ItemName: String);
begin
    ItemTag := Target;
end;

procedure TForm3.RichViewEdit1WriteHyperlink(Sender: TCustomRichView;
  id: Integer; RVData: TCustomRVData; ItemNo: Integer;
  SaveFormat: TRVSaveFormat; var Target, Extras: String);
begin
  Target := RVData.GetItemTag(ItemNo);
end;
And rvoTagsArePChars is not used any more.
Post Reply