Esempio n. 1
0
        /// <summary>
        /// Returns the topmost control at the specified coordinate.
        /// </summary>
        /// <param name="cc">The control collection.</param>
        /// <param name="p">The coordinate.</param>
        /// <returns>
        /// If there is a control at the position the topmost, otherwise null.
        /// </returns>
        protected static Control GetTopControlAt(ControlCollection cc, Point p)
        {
            for (int i = cc.Count - 1; i >= 0; i--)
            {
                Control c = cc.GetControlByZOrder(i);

                if (c.HitTest(p))
                {
                    return(GetTopControlAt(c.Controls, p) ?? c);
                }
            }

            return(null);
        }