GetChildAtPoint returns only disabled controls?
I'm using the following example to show a tooltip above a disabled button. How can 开发者_Go百科I show a tooltip on a disabled button?
The button is inside a panel and I attach the MouseMove event to the panel, not the form itself. Surprisingly, GetChildAtPoint returns null if the button is enabled! The button is returned only when it is disabled. I've checked the location of the button and it is the same when enabled and when disabled, and both times its parent is the panel.
To be clear; MouseMove event is called on all controls, and inside it there is a usage in GetChildAtPoint method. When the button is enabled, MouseMove is called and GetChildAtPoint returns null. When it is disabled, MouseMove is called and GetChildAtPoint returns the button.
I don't understand why this code works. Any help is greatly appreciated, thanks.
You're calling GetChildAtPoint from WM_MOUSEMOVE which is sent to the window under the mouse. Disabled controls do not receive WM_MOUSEMOVE, so it gets sent to the parent. Enabled controls get the message themselves, the parent doesn't get it.
精彩评论