Exemplo n.º 1
0
        /// <summary>
        /// Excludes the specified child control from the glass effect.
        /// </summary>
        /// <param name="parent">The parent control.</param>
        /// <param name="control">The control to exclude.</param>
        /// <exception cref="ArgumentNullException">Occurs if control is null.</exception>
        /// <exception cref="ArgumentException">Occurs if control is not a child control.</exception>
        public static void ExcludeChildFromGlass(this Control parent, Control control)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }
            if (!parent.Contains(control))
            {
                throw new ArgumentException("Control must be a child control.");
            }

            if (IsCompositionEnabled())
            {
                System.Drawing.Rectangle clientScreen  = parent.RectangleToScreen(parent.ClientRectangle);
                System.Drawing.Rectangle controlScreen = control.RectangleToScreen(control.ClientRectangle);

                NativeMethods.Margins margins = new NativeMethods.Margins(controlScreen.Left - clientScreen.Left, controlScreen.Top - clientScreen.Top,
                                                                          clientScreen.Right - controlScreen.Right, clientScreen.Bottom - controlScreen.Bottom);

                // Extend the Frame into client area
                NativeMethods.DwmExtendFrameIntoClientArea(parent.Handle, ref margins);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Extends the window frame beyond the client area.
 /// </summary>
 /// <param name="window">The window.</param>
 /// <param name="padding">The padding to use as the area into which the frame is extended.</param>
 public static void ExtendFrameIntoClientArea(this IWin32Window window, Padding padding)
 {
     if (window == null)
     {
         throw new ArgumentNullException(nameof(window));
     }
     NativeMethods.Margins m = new NativeMethods.Margins(padding);
     NativeMethods.DwmExtendFrameIntoClientArea(window.Handle, ref m);
 }