Hot Text

This is code for Hot Text component. This component is TLabel componet add to it new method. This label will change its color to Red when the mouse enter it, and go back to Black when the mouse leaves it.

Things to add

  • New property for the Hot Color.
  • New events, on mouse enter, and on mouse leaves.
  • The Component should keep the original color to chage it back when the mouse leave.
  • unit HotText;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;
    
    type
      THotText = class(TLabel)
      private
        { Private declarations }
         procedure CMEnter (var m:TMsg); message CM_MOUSEENTER;
         procedure CMLeave (var m:TMsg); message CM_MOUSELEAVE;
      end;
    
    procedure Register;
    
    implementation
    
    procedure Register;
    begin
      RegisterComponents('Samples', [THotText]);
    end;
    
    procedure THotText.CMEnter ;
    begin
     font.color:= clNavy;
    end;
    
    procedure THotText.CMLeave ;
    begin
     font.color:= clBlack;
    end;
    
    end.
     
    BACK