Code below "HotTracks" Labels and Check Boxes, with a little modification use it to HotTrack any control.
~~~~~~~~~~~~~~~~~~~~~~~~~
{We have to override the WndProc procedure}
procedure WndProc(var Message : TMessage) ; override ;
procedure TForm1.WndProc(var Mesg : TMessage) ;
begin
{ Here we see which component gets changed.
This bit here tells us which
component the mouse is over }
if Mesg.LParam = Longint(Label1) then
ChangeColor(Label1, Mesg.Msg) ;
if Mesg.LParam = Longint(Label2) then
ChangeColor(Label2, Mesg.Msg) ;
if Mesg.LParam = Longint(Label3) then
ChangeColor(Label3, Mesg.Msg) ;
if Mesg.LParam = Longint(CheckBox1) then
ChangeColor(CheckBox1, Mesg.Msg) ;
inherited WndProc(Mesg) ;
end;
procedure TForm1.ChangeColor
(Sender : TObject; Msg : Integer) ;
Begin
{ If a label is the one that the mouse
is over then we do this }
if Sender IS TLabel Then
begin
if (Msg = CM_MOUSELEAVE) then
(Sender As TLabel).Font.Color:=clWindowText;
if (Msg = CM_MOUSEENTER) then
(Sender As TLabel).Font.Color:=clBlue;
end;
{ If a CheckBox is the one ... }
if Sender IS TCheckBox Then
begin
if (Msg = CM_MOUSELEAVE) then
(Sender As TCheckBox).Font.Color:=clWindowText ;
if (Msg = CM_MOUSEENTER) then
(Sender As TCheckBox).Font.Color:=clRed ;
end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Delphi tips navigator:
» Send an email (with attachment) from Outlook
« Abort a loop by pressing a key

