Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1.96 KB

Example2.md

File metadata and controls

52 lines (40 loc) · 1.96 KB

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;

Links