Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get control under mouse cursor? [duplicate]

Tags:

c#

winforms

mouse

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.

like image 682
Poma Avatar asked Mar 09 '10 17:03

Poma


People also ask

How to change the cursor in c#?

The primary way to change the mouse pointer is by setting the Control. Cursor or DefaultCursor property of a control to a new Cursor. For examples of changing the mouse pointer, see the code example in the Cursor class.

How do I change the cursor in Visual Studio?

Thankfully the solution is quick and simple: Open Control Panel | Appearance and Personalization | Personalization | Change mouse pointers.


1 Answers

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

like image 82
Philip Fourie Avatar answered Oct 16 '22 01:10

Philip Fourie