Catching mouse events on all child controls

B

Bytter

Greetings,

I've already tried googling for the following problem, but it seems
every solution I've found is too complex and error prone.

I've got a control (Panel) that acts as a container for several other
controls. These controls, in turn, have several other controls and so
on. I wish to be notified whenever the mouse is hover the area defined
by the container control, regardless of its children. OnMouseEnter and
OnMouseLeave triggers as soon as the mouse enters/leaves a child
control, so I can't use them. Same applies for OnGotFocus/OnLostFocus.

One solution would be to hook upon all events in every child control.
Despite the resulting complexity of event triggering (and the fact
that some controls can simply override the events I'm listening for
and inhibit them), the controls I'm using can (and will) change in run-
time (we are talking about adaptative interfaces here); this would
probably mean that I also need to hook upon the ControlAdded and
ControlRemoved events.

So my question is simple: is there any "clean" way for a control to
know that a mouse is in its area (ClientRectangle)? I don't mind if
the solution involves WndProc...

Best regards and thanks in advance,

Hugo Ferreira
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top