示例#1
0
文件: PinForm.cs 项目: tesys25/pinwin
        /// <summary>
        ///  Calculates total width of control buttons (minimize, maximize, close).
        /// </summary>
        /// <param name="handle">Window handle.</param>
        /// <returns>Total width in pixels.</returns>
        private static int GetControlAreaWidth(IntPtr handle)
        {
            WindowStyle style       = new WindowStyle(handle);
            int         buttonCount = style.MaximizeBox || style.MinimizeBox ? 3 : 1;

            int controlButtonAverageWidth = ApiSystemMetrics.Get(SystemMetric.SM_CXSIZE);

            return(controlButtonAverageWidth * buttonCount);
        }
示例#2
0
        /// <summary>
        ///  Get total computed width of control box area (minimize, maximize and close buttons).
        /// </summary>
        /// <returns>Total width in pixels.</returns>
        public int GetControlBoxWidth()
        {
            int controlBoxWidth = ApiSystemMetrics.GetControlBoxWidth(this.Handle);

            if (controlBoxWidth > 0)
            {
                return(controlBoxWidth);
            }

            // legacy OS
            int buttonCount = this.MaximizeBox || this.MinimizeBox ? 3 : 1;
            int controlButtonAverageWidth = ApiSystemMetrics.GetControlButtonWidth();

            return(controlButtonAverageWidth * buttonCount);
        }