whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

38 Visitors Online


 
...use CM_MOUSEENTER and CM_MOUSELEAVE in a component?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (13):  
     


{
 Folgende unit ist eine visuelle Komponente abgeleitet von TImage, welche
 zusätzlich die 2 Ereignisse OnMouseEnter und OnMouseLeave beinhaltet.
}

{
 The following unit is a visual component inherited of TImage, which has the
 2 additional events OnMouseEnter and OnMouseLeave.
}

unit ImageEx;

interface

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

type
  
TImageEx = class (TImage)
  private
    
{ Private declarations }
    
FOnMouseLeave: TNotifyEvent;
    FOnMouseEnter: TNotifyEvent;
    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: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent 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.

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners