Article View: comp.lang.pascal.delphi.misc
Article #440Re: Hot to implement MouseEnter and MouseExit with SpeedButton ??
From: Dave Shapiro
Date: Fri, 30 Apr 1999 00:00
Date: Fri, 30 Apr 1999 00:00
82 lines
3097 bytes
3097 bytes
Reid Roman wrote:
>
> Eric wrote:
> >
> > Hello,
> >
> > Would you please to give me a simple example to implement MouseEnter and
> > MouseExit on SpeedButton ????
>
> Use the onmousemove event for the form, this gives you the x and y
> co-ordinates of the mouse pointer, something like:
This technique might not give you all the right results. For instance,
what if, on form creation, the cursor is inside the button? The event
doesn't get triggered immediately. If it's not too much of a pain (i.e.
you've already got a zillion TSpeedButtons created), you might consider
writing your own TSpeedButton descendent that traps the MOUSEENTER and
MOUSELEAVE message. Here's an example:
unit PsSpeedButton;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, Buttons;
type
TPsSpeedButton = class(TSpeedButton)
private
protected
FOnMouseEnter: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
procedure DoMouseEnter; virtual;
procedure DoMouseLeave; virtual;
procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
public
published
property OnMouseEnter: TNotifyEvent read FOnMouseEnter
write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave
write FOnMouseLeave;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Professional Software', [TPsSpeedButton]);
end;
procedure TPsSpeedButton.DoMouseEnter;
begin
if Assigned(OnMouseEnter) then OnMouseEnter(Self);
end;
procedure TPsSpeedButton.DoMouseLeave;
begin
if Assigned(OnMouseLeave) then OnMouseLeave(Self);
end;
procedure TPsSpeedButton.CMMouseEnter(var Msg: TMessage);
begin
DoMouseEnter;
end;
procedure TPsSpeedButton.CMMouseLeave(var Msg: TMessage);
begin
DoMouseLeave;
end;
end.
Dave
--
http://www.csd.net/~daves
Technical Details
Message-ID:
<3729E729.45AA0E6@cfxc.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<372925B3.9D95827E@sftw.umac.mo> <3729BFD7.D58959E0@home.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb0ea,161c96c908e39ff X-Google-Attributes: gidfb0ea,public X-Google-Thread: fd817,161c96c908e39ff X-Google-Attributes: gidfd817,public X-Google-Thread: 10baee,161c96c908e39ff X-Google-Attributes: gid10baee,public X-Google-Thread: 1043cf,161c96c908e39ff X-Google-Attributes: gid1043cf,public X-Google-Thread: 10c3d1,161c96c908e39ff X-Google-Attributes: gid10c3d1,public From: Dave Shapiro <daves@cfxc.com> Subject: Re: Hot to implement MouseEnter and MouseExit with SpeedButton ?? Date: 1999/04/30 Message-ID: <3729E729.45AA0E6@cfxc.com> X-Deja-AN: 472815154 Content-Transfer-Encoding: 7bit References: <372925B3.9D95827E@sftw.umac.mo> <3729BFD7.D58959E0@home.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: a Mime-Version: 1.0 Newsgroups: comp.lang.pascal.delphi.misc,alt.comp.lang.borland-delphi,borland.public.delphi.objectpascal,borland.public.delphi.vcl.components,borland.public.delphi.vcl.components.using