{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} { Downloaded from The Coder's Knowledge Base } { http://www.netalive.org/ckb/ } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} { @ CKB Header Version.: 1.01 } { @ Category ID........: delphi_misc } { @ Added to database..: 10.11.98 } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} { @ Title..............: Mouse move } { @ Original Filename..: mousemove.txt } { @ Author.............: Bent Normann Olsen (normann@greennet.gl) } { @ Description........: Highlight a comp by mouse move } { @ Tested w. Compiler.: not tested yet } { @ Submitted by.......: Unofficial Delphi Developers FAQ (uddf@gnomehome.demon.nl) } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} I want to write a component which highlights when the user moves the mouse over the comp. Use CM_MOUSEENTER and CM_MOUSELEAVE messages like: TYourObject = class(TAnyControl) private FMouseInPos : Boolean; procedure CMMouseEnter(var AMsg: TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var AMsg: TMessage); message CM_MOUSELEAVE; end; implementation procedure TYourObject.CMMouseEnter(var AMsg: TMessage); begin FMouseInPos := True; Refresh; end; procedure TYourObject.CMMouseLeave(var AMsg: TMessage); begin FMouseInPos := False; Refresh; end; ...and then read FMouseInPos when painting the control, or in any way you like to change the highlightning.