Author: Mike Shkolnik
How can I add the hot track effect to my component?
Answer:
If you want to add a useful feature to your component (like URL in html or
PageControl/TabControl.HotTrack) you must handle the CM_MOUSEENTER and
CM_MOUSELEAVE messages:
1 type2 TyourControl = class(TDescControl)
3 private4 { Private declarations }5 FLinkFont: TFont;
6 FPassiveFont: TFont;
7 8 procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
9 procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
10 end;
11 12 implementation13 14 procedure TyourControl.CMMouseEnter(var Msg: TMessage);
15 begin16 //Change color when mouse is over control17 Font.Assign(FLinkFont);
18 end;
19 20 procedure TyourControl.CMMouseLeave(var Msg: TMessage);
21 begin22 //Change color when mouse leaves control23 Font.Assign(FPassiveFont);
24 end;
As example, you can view a sources of the TURLLabel and/or THighLightLabel components on my site (http://www.geocities.com/mshkolnik