How do I make the control invisible but react 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 I move the mouse over a custom control). I thought that overriding the paint method and leaving it blank would do the job, but unfortunately the rectangle is drawn where the component is.

How can I make the control completely invisible?

+2


source to share


2 answers


You can inherit from TGraphicControl

instead of TCustomControl

and leave the paint handler empty. Nothing will be drawn.



If you want a windowed control, then you need to make sure it has no border and uses its parent background. See this question for information on how to do this. You may need to override CreateParams()

to remove the border style bit.

+9


source


If the control is not visible, handle the click messages in the parent, run a simple test on those in the control rectangle, and use PostMessage to forward the message to the control. Such code can be more readable than empty handlers. Bree



+1


source







All Articles