[DUG] Mouse over form

Conor Boyd Conor.Boyd at trimble.co.nz
Mon Jul 3 08:33:27 NZST 2006


Here's a partial suggestion.

  TForm1 = class(TForm)
	...
  private
    { Private declarations }
    procedure WMNCHitTest(var Msg:TMessage); message WM_NCHITTEST;
  end;

procedure TForm1.WMNCHitTest(var Msg: TMessage);
begin
  // This message will be received by your form whenever the mouse is
over it,
  // including the title bar and borders, etc.
  // So you can log the fact and do whatever else you need.

  // I don't think it'll help you know _when_ the mouse leaves the form,
  // but hopefully it's some help anyway.
end; 

HTH,

Conor

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
On Behalf Of John Bird

I wish to have a small form be mainly transparent and less transparent
when the mouse moves over it.  The form onMouseEnter and onMouseLeave
are almost perfect, except that moving the mouse to any components on
the form also fires the onMouseLeave event, and the border/title bar
also is not counted as part of the form either.

Question - Is there any way to detect the mouse is anywhere within the
form without having to put mouse events on all components or doing a
continuous monitoring of the mouse position?

The best solution I have so far is to reduce the transparency of the
form on MouseEnter, and leave it so for a few seconds before making it
more transparent again after a few seconds...but its not ideal as this
can happen if the mouse is still within the form.

(One reason I don't want to put events into the components is that one
of them a colorbutton already has a mouseover event to change color)



More information about the Delphi mailing list