- Code: Select all
unit MenuItemEx;
interface
uses
Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,
Dialogs,ExtCtrls, menus;
type
TMenuItemEx=class (TMenuItem)
private
{ Private declarations }
FOnMouseLeave:TNotifyEvent;
FOnMouseEnter:TNotifyEvent;
procedure CM_MouseEnter( var msg:TMessage); message CM_MOUSEENTER;
procedure CM_MouseLeave( var msg:TMessage); message CM_MOUSELEAVE;
protected
{ Protected declarations }
procedure DoMouseEnter;dynamic;
procedure DoMouseLeave;dynamic;
public
{ Public declarations }
published
{ Published declarations }
property OnMouseEnter:TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave:TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents( 'Samples',[TMenuItemEx]);
end;
procedure TMenuItemEx.CM_MouseEnter( var msg:TMessage);
begin
DoMouseEnter;
end;
procedure TMenuItemEx.CM_MouseLeave( var msg:TMessage);
begin
DoMouseLeave;
end;
procedure TMenuItemEx.DoMouseEnter;
begin
if Assigned( FOnMouseEnter) then FOnMouseEnter( Self);
end;
procedure TMenuItemEx.DoMouseLeave;
begin
if Assigned( FOnMouseLeave) then FOnMouseLeave( Self);
end;
end.
But the events don not fire.
Any ideas?