Jump to content
#ifdef

TPanel + Mouse

Recommended Posts

I disabled both labels, but the panel does not respond if the cursor is over the label.

 

How to fix it?

1.gif

Share this post


Link to post

Select both label and panel to set MouseEnter and MouseLeave event handler or assign same event handler to both components.

Share this post


Link to post

Just because the Labels are disabled does not mean the Panel will handle mouse activity when over them.  You are still mousing over the Labels, so you need to catch and forward the event activity from the Labels if you want to handle them the same as events on the Panel.

 

Otherwise, you can subclass the Panel to handle the underlying mouse messages before they get dispatched to children.  Since the Panel is a windowed control and the Labels are graphical controls, the Panel is the one receiving the messages from the OS and passing them along to the Labels.

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×