Ajouter les evenements MouseEnter & MouseLeave sur vos composants

unit ImageEx;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TImageEx = class (TImage)
private
{ Private declarations }
FOnMouseLeave: TNot if yEvent;
FOnMouseEnter: TNot if yEvent;
procedure CMMouseEnter( var msg: TMessage);
message CM_MOUSEENTER;
procedure CMMouseLeave( var msg: TMessage);
message CM_MOUSELEAVE;
protected
{ Protected declarations }
procedure DoMouseEnter; dynamic;
procedure DoMouseLeave; dynamic;
public
{ Public declarations }
published
{ Published declarations }
property OnMouseEnter: TNot if yEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave: TNot if yEvent read FOnMouseLeave write FOnMouseLeave;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Additional', [TImageEx]);
end;

{ TImageEx }

procedure TImageEx.CMMouseEnter( var msg: TMessage);
begin
DoMouseEnter;
end;

procedure TImageEx.CMMouseLeave( var msg: TMessage);
begin
DoMouseLeave;
end;

procedure TImageEx.DoMouseEnter;
begin
if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);
end;

procedure TImageEx.DoMouseLeave;
begin
if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;

end.
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour10/12/2004
VisualisationVu 1250 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Objet
Auteur de l'article
SwissDelphiCenter SwissDelphiCenter
connecté le 02/11/2011
329 articles dans la section
Contacter l'auteur