Page 1 of 1

HTML Buttons

Posted: Fri Jun 15, 2007 2:04 pm
by worksmart
Hi

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

Thanks

Mike

Posted: Tue Jun 19, 2007 11:20 am
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?

Posted: Wed Jun 20, 2007 5:48 am
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

Posted: Wed Jun 20, 2007 6:00 am
by worksmart
On a different note

Can the html convserion cope with url link?

Posted: Wed Jun 20, 2007 1:06 pm
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.