Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1124
  • Last Modified:

OnMouseEnter and OnMouseLeave

What kind of trick to implement that ?

I want to make a descendant of TImage that have those events.

Anyone willing to share the codes ?

Thanks.
0
muis2002
Asked:
muis2002
  • 2
1 Solution
 
kretzschmarCommented:
just catch the messages

CM_MOUSEENTER
CM_MOUSELEAVE

sample follows

meikl ;-)
0
 
kretzschmarCommented:
well, the sample:

unit Meiklimage;

interface

uses
  SysUtils, Classes, Controls, ExtCtrls, messages;

type
  TMeiklimage = class(TImage)
  private
    fOnMouseEnter : TNotifyEvent;
    fOnMouseLeave : TNotifyEvent;
  protected
    procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
  public
    { Public declarations }
  published
    property OnMouseEnter : TNotifyEvent read fOnMouseEnter write fOnMouseEnter;
    property OnMouseLeave : TNotifyEvent read fOnMouseLeave write fOnMouseLeave;
  end;



procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TMeiklimage]);
end;

procedure TMeiklimage.CMMouseEnter(var Msg: TMessage);
begin
  if assigned(fOnMouseEnter) then
    fOnMouseEnter(self);
  inherited;
end;

procedure TMeiklimage.CMMouseLeave(var Msg: TMessage);
begin
  if assigned(fOnMouseLeave) then
    fOnMouseLeave(self);
  inherited;
end;


end.


meikl ;-)
0
 
muis2002Author Commented:
Thanks meikl :)
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now