How to get control under mouse cursor?

Poma picture Poma · Mar 9, 2010 · Viewed 47.5k times · Source

I have form with few buttons and I want to know what button is under cursor now.

P.S. Maybe it's duplicate, but I can't find answer to this question.

Answer

Philip Fourie picture Philip Fourie · Mar 9, 2010

Have a look at GetChildAtPoint. You will have to do some extra work if the controls are contained in a container, see Control.PointToClient.