Realize MouseOut and MouseIn

How do realize "mouseOut and mouseIn" for "Label" Control?
ourAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
hi,
use the cmmouseEnter/Leave events as demonstrated in this component:

unit ColorLabel;
 
{
  Komponente die sobald die Maus ueber dem Label ist die Farbe der Caption
  ins Value von "Highlight" aendert und bei verlassen des Bereiches wieder
  auf "ColorNormal" zuruecksetzt.
(c) 1999 by Christian Schiffler
}
 
interface
 
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;
 
type
  TColorLabel = class(TLabel)
  private
    { Private declarations }
    FColorNormal,
    FColorHighLight: TColor;
    FMouseInPos: Boolean;
    FMouseEnter, fMouseExit:TNotifyEvent;
    Procedure CMMouseEnter(var AMsg: TMessage); message CM_MouseEnter;     Procedure CMMouseLeave(var AMsg: TMessage); message CM_MouseLeave;     Constructor Create(AOwner:TComponent); override;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    Property ColorNormal:TColor Read FColorNormal Write FColorNormal;     Property HighLight:TColor Read FColorHighLight Write
FColorHighLight;
    Property MouseInPos:Boolean Read FMouseInPos Write FMouseInPos;     Property OnMouseEnter:TNotifyEvent Read FMouseEnter Write
FMouseEnter;
    Property OnMouseExit:TnotifyEvent Read FMouseExit Write FMouseExit;   end;
 
procedure Register;
 
implementation
 
procedure Register;
begin
  RegisterComponents('Samples', [TColorLabel]);
end;
 
Constructor TColorLabel.Create(AOwner:TComponent);
Begin;
  Inherited Create(AOwner);
  FColorNormal:= Font.Color;
  FColorHighLight:=clHighLightText;
End;
 
Procedure TColorLabel.CMMouseEnter(var AMsg: TMessage);
Begin;
  Font.Color:=FColorHighLight;
  FMouseInPos:=True;
  If Assigned(FMouseEnter) Then FMouseEnter(Self) Else Refresh;
end;
 
Procedure TColorLabel.CMMouseLeave(var AMsg: TMessage);
Begin;
  Font.Color:=FColorNormal;
  FMouseInPos:=False;
  If Assigned(FMouseExit) Then FMouseExit(Self) Else Refresh;
End;
 
End.




Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bryan7Commented:
listenning
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.