Einzelnen Beitrag anzeigen

HPW

Registriert seit: 28. Feb 2003
160 Beiträge
 
Delphi 7 Professional
 
#8

Re: TMenuItem mit OnSelect/MouseOver ?

  Alt 24. Sep 2007, 16:45
Hab mal versucht das hinzubekommen:
Delphi-Quellcode:
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.
Die Events feuern aber nicht.
Hans-Peter
  Mit Zitat antworten Zitat