You'll need to filter queued messages to detect mouse events at a global level.
- Add a handler for
TApplication.OnMessage
. - Listen to
WM_MOUSEDOWN
orWM_MOUSEUP
as you please, and respond if the target window handle is that of the form, or a child control. - Make sure you leave the Handled parameter of the message as False so that the message is delivered to its target.
If you really are trying to detect form activation, use OnActivate
.