How to detect if the mouse is inside the whole form and child controls?

前端 未结 4 1698
长发绾君心
长发绾君心 2020-12-06 02:23

I need to detect when the user moves the mouse over the Form and all its child controls and also when it leaves the Form. I tried the MouseEnter and Mouse

4条回答
  •  孤街浪徒
    2020-12-06 03:20

    Quick and dirty solution:

    private bool MouseInControl(Control ctrl)
    {
        return ctrl.Bounds.Contains(ctrl.PointToClient(MousePosition));
    }
    

提交回复
热议问题