delphilinklabel

Is Delphi's TLinkLabel broken?


procedure Tform_About.FormCreate(Sender: TObject);
begin
  inherited;  // <- GenericBase form
  //
  linklabel_EULA.Caption := 'Visit <a href="https://www.example.com">Website</a> or view <a href="#EULA">EULA</a>.';
end;

//----------------------------------------------------------------------------------------------------------------------
procedure Tform_About.linklabel_EULALinkClick(Sender: TObject; const Link: String; LinkType: TSysLinkType);
begin
  case LinkType of
    sltID:  HandleIDLink(Link);
    sltURL: ShellExecute(0, 'open', PChar(Link), nil, nil, SW_SHOWNORMAL);
  end;
end;

After clicking on 'EULA', the Link parameter of the LinkClick procedure comes in correctly as '#EULA', however the LinkType parameter is sltURL. Any ideas? A bug?


Solution

  • No, this works as designed.

    Link type sltURL is used for all href links:

    <a href="something">Link caption</a>
    

    Link type sltID is used for all id links:

    <a id="something">Link caption</a>
    

    This is documented at MSDN.