size : 975
uploaded_on : Thu Oct 14 00:00:00 1999
modified_on : Wed Dec 8 14:02:54 1999
title : Detect mouse over control
org_filename : MouseOverComp.txt
author : Steve Bliss
authoremail : steve@globacon.com
description : How to detect if the mouse is over a component
keywords :
tested : not tested yet
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : nobody
modified_by : nobody
owner : nobody
lang : plain
file-type : text/plain
category : delphi-commoncontrols
__END_OF_HEADER__
You will need to use the CM_MOUSEENTER and CM_MOUSEEXIT messages in a
derived component. There may be other ways, but that is
the only one I know of. Look at "Controls.pas" for info on these
messages and others.
in the "private" section of the descendant class add:
-----------------------------------------------------
bOverComponent: boolean
procedure CMMouseEnter( var Msg: TMessage); message CM_MouseEnter;
procedure CMMouseLeave( var Msg: TMessage); message CM_MouseLeave;
in the handlers for above:
---------------------------
procedure TPsiThunderButton.CMMouseEnter( var Msg: TMessage);
begin
inherited;
if not bOverComponent then begin
;
Invalidate
end;
bOverComponent := true
end;
-------------
procedure TPsiThunderButton.CMMouseLeave(var Msg: TMessage);
begin
inherited;
if bOverComponent then begin
;
Invalidate
end;
bOverComponent := false
end;