TLaunchlabel is a subclass of TCustomLabel, this is a label which doesn't have all the properties
of a label, but he does own them. Only properties listed in the published section will show up
in the object inspector.
 
unit LaunchLabel;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ShellApi;
type
  TLaunchLabel = class(TCustomLabel) 
  private
    FLaunch: String;
    procedure SetLaunch(const Value: String);
    { Private declarations }
  protected
    { Protected declarations }
    procedure MouseEnter (var Msg : TMessage);
        message cm_mouseEnter;
    procedure MouseLeave (var Msg : TMessage);
        message cm_mouseLeave;
    procedure Click; override;
  public
    { Public declarations }
  published
    { Published declarations }
    property Launch :String read FLaunch write SetLaunch;
    property AutoSize;
    property Caption;
    property Enabled;
    property FocusControl;
    property Font;
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property ShowHint;
    property Transparent;
    property Visible;

  end;


procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MijnComponentPage', [TLaunchLabel]); Here is TLaunchLabel registered
end;


procedure TLaunchLabel.Click; ShellExecute "launcht" the app, when the returned value <=32 is
Var X:String;                 the focus will be moved to control specified in de property Focuscontrol

begin
  Inherited click;
  x:=FLaunch;
  if ShellExecute(0, nil, PChar(x), nil, nil, SW_SHOWDEFAULT) <= 32 then // NoCanDoLaunch
    if Assigned(FocusControl) then FocusControl.SetFocus;  //TryToFocus a control
end;


procedure TLaunchLabel.MouseEnter(var Msg: TMessage);
begin
  Font.Color:=clBlue;
  Font.Style:=Font.Style+[fsUnderLine];
  Cursor:=crHandPoint;
end;

procedure TLaunchLabel.MouseLeave(var Msg: TMessage);
begin
  Font.Color:=clWindowText;
  Font.Style:=Font.Style-[fsUnderLine];
  Cursor:=crDefault;
end;

procedure TLaunchLabel.SetLaunch(const Value: String);
begin
  FLaunch := Value;
  Caption:=Value;
end;

end.

wpe10.jpg (17261 bytes)