[DUG] Mouse over form

John Bird johnkbird at paradise.net.nz
Mon Jul 3 16:32:17 NZST 2006


Thanks for that  - That's one I would not have known - is there somewhere to
read more on it?  From Google it looked like relating to mouse clicks on the
form, whereas I wanted to get an event with just mouse over the form...

I tried it a bit, and it seemed to sort of work, I hadn't got the leave part
working yet, and also it seemed to disable the applications X (ie windows
close) button.  That is not necessarily a problem, as I have been toying
with making it a borderless form anyway.

John 

-----Original Message-----
From: Conor Boyd [mailto:Conor.Boyd at trimble.co.nz] 
Sent: Monday, 3 July 2006 8:33 a.m.
To: johnkbird at paradise.net.nz; NZ Borland Developers Group - Delphi List
Subject: RE: [DUG] Mouse over form


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)


__________ NOD32 1.1461 (20060329) Information __________

This message was checked by NOD32 antivirus system. http://www.eset.com





More information about the Delphi mailing list