Skip over navigation

Hot Label Component

Label component that accesses a URL when clicked

Version 2.2.1
Released 2016-02-14
Platforms Win32 & Win64
Framework VCL
Compatibilty Delphi 7 and later

Overview

TPJHotLabel is a simple Delphi component that descends from TLabel. It provides a clickable label that can start the default browser or email client to access a specific URL.

Key features of the component are:

  • All properties of TLabel are supported, although the usage and default values of some of the inherited properties have been changed.
  • The URL property is used for storing the URL to be accessed when the label is clicked. The Caption property can either store descriptive text or can reflect the URL, depending on the value of the CaptionIsURL property. The ability to link the Caption and URL makes it easy to display the URL without having to keep two properties synchronised.
  • The URL can be validated to check for supported protocols. This validation is switched on and off using the ValidateURL property. Supported protocols are:
    • http://
    • https://
    • mailto:
    • file:
    • ftp://
  • The label's Font property defaults to navy blue to indicate a link.
  • The label can be highlighted when the mouse passes over it. Highlighting is used if the HighlightURL property is True, and the font used for highlighting is set using the HighlightFont property.
  • The label can also display differently when its "link" has been clicked successfully. The font to be used is specified via the VistedFont property. The user can switch the visited state on and off via the Visited property or the component can be enabled to track visits automatically using the TrackVisits property.
  • The label displays the "hand point" cursor by default.
  • The component's pop-up hints can be customised as follows, using the HintStyle property:
    • the hint text can come from the Hint property as normal,
        or
    • the hint text can come from the URL property with the Hint property being ignored,
        or
    • the hint text can be modified just before the hint is shown by handling the OnCustomHint event, which is useful for displaying dynamic information in the hint.

A demo program is included in the download. See the Demo sub-directory.

The component functions mainly as a standard TLabel except that:

  1. It handles the Delphi-specific CM_MOUSEENTER and CM_MOUSELEAVE messages to highlight the label when the mouse is over it.
  2. It handles Delphi's CM_HINTSHOW message to provide customised hints.
  3. The Caption property may automatically change when the optionally linked URL property changes.

TPJHotLabel uses the Windows ShellAPI ShellExecute function to start the default browser or email client when a URL is clicked.

Get The Code

You can download the latest version of the Hot Label Component directly from SourceForge as dd-hotlabel-2.2.1.zip.

Download v2.2.1

The Hot Label Component source code is hosted in the ddablib/hotlabel GitHub repository. You can git clone or fork the repository as required.

Installation

The Hot Label Component is supplied in a zip file. Before installing you need to extract all the files from the zip file, preserving the directory structure. The following files will be extracted:

  • PJHotLabel.pas – component source code.
  • PJHotLabel.dcr – component palette glyphs.
  • ReadMe.htm – read-me file.
  • ChangeLog.txt – project change log.
  • MPL-2.txt – the Mozilla Public License v2.0.
  • Documentation.URL – short-cut to the component's online documentation.

In addition to the above files you will find the source code of the demo project the Demo sub-directory.

You can now install the components into the Delphi IDE. To do this, the files PJHotLabel.pas and PJHotLabel.dcr should be added to a design time package. If you need help doing this see here.

Documentation

The Hot Label Component is comprehensively documented online here

The project's change log can be viewed here.

A read-me file (ReadMe.htm) is included in the project download.

Feedback & Queries

If you find any bugs or want to suggest a new feature please report them using the Hot Label Component issue tracker.

If you have created a bug fix or have implemented a new feature please open a pull request for it.

Should you have any queries about using the component please read the documentation. If you can't find an answer in the documentation then post a message in the discussion group.

License

The Hot Label Component is open source. It is copyright © 1999-2016 by Peter Johnson. The source code is made available under the terms of the Mozilla Public License v2.0. All relevant trademarks are acknowledged.