简单示例如下:(给自定义label控件增加自定义鼠标事件)
type
TNewLabel=class(TLabel)
private
procedure CMMouseEnter(var Msg:TMessage);message CM_MOUSEENTER;
procedure CMMouseLeave(var Msg:TMessage);message CM_MOUSELEAVE;
implementation
procedure TKvLabel.CMMouseEnter(var Msg:TMessage);
begin
if FLinkType then
begin
Cursor:=crHandPoint;
FOldColor:=Font.Color;
Font.Color:=FAboveColor;
Font.Style:=Font.Style+[fsUnderline];
end;
end;
procedure TKvLabel.CMMouseLeave(var Msg:TMessage);
begin
if FLinkType then
begin
Cursor:=crDefault;
Font.Color:=FOldColor;
Font.Style:=Font.Style-[fsUnderline];
end;
end;