jpfollenius
jpfollenius

Reputation: 16612

How to make control invisible but responsive to mouse events?

I want to create a control (derived from TCustomControl) that is invisible but reacts to normal events (I want to use it to show a hint when moving the mouse over a custom element). I thought overriding the paint method and leaving it empty would do the job but unfortunately a rectangle is drawn where the component is.

How can I make the control completely invisible?

Upvotes: 2

Views: 505

Answers (2)

Brian Frost
Brian Frost

Reputation: 13454

If the control is not visible then process click messages in the parent, do a simple test for those being in the control's rectangle and use PostMessage to forward the message to the control. Such code may be more readable than empty paint handlers. Bri

Upvotes: 1

mghie
mghie

Reputation: 32334

You can inherit from TGraphicControl instead of from TCustomControl, and leave the paint handler empty. Nothing will be drawn.

If you need a windowed control, then you should make sure that it has no border and uses the parent background. See this question for info on how to do that. You may need to override CreateParams() as well, to remove the border style bits.

Upvotes: 9

Related Questions