Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

Examples: Using the OnCustomHint Event

Applies to: ~>2.0

These examples show how to use the OnCustomHint event of TPJHotLabel. We handle the event to display a hint containing some descriptive text along with the URL in brackets.

Example 1

Drop a TPJHotLabel component on a form and create a FormCreate and a OnCustomHint event handler, completed as follows:

procedure TForm1.FormCreate(Sender: TObject);
begin
  // You *could* set these properties at design time in the object inspector
  // instead of setting them here
  PJHotLabel1.URL := 'https://delphidabbler.com/';
  PJHotLabel1.HintStyle := hsCustom;
  PJHotLabel1.ShowHint := True;
end;

procedure TForm1.PJHotLabel1CustomHint(Sender: TObject; var HintStr: string);
begin
  HintStr := Format('View the site''s index page (%s)',  [PJHotLabel1.URL]);
end;

Example 2

This example is similar to the first except we store the custom hint text in the Hint property rather than entering the text in the form unit. This keeps the form’s text in the form file. Drop a TPJHotLabel component on a form and create a FormCreate and a OnCustomHint event handler as before, and complete them as follows:

procedure TForm1.FormCreate(Sender: TObject);
begin
  // You *could* set these properties at design time in the object inspector
  // instead of setting them here
  PJHotLabel1.Hint := 'View the site''s index page (%s)';
  PJHotLabel1.URL := 'https://delphidabbler.com/';
  PJHotLabel1.HintStyle := hsCustom;
  PJHotLabel1.ShowHint := True;
end;

procedure TForm1.PJHotLabel1CustomHint(Sender: TObject; var HintStr: string);
begin
  HintStr := Format(HintStr, [PJHotLabel1.URL]);
end;