Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Msg"></param>
        private void WmNcPaint(ref Message Msg)
        {
            base.WndProc(ref Msg);

            if (base.BorderStyle == BorderStyle.None)
            {
                return;
            }

            IntPtr hDC = ListViewNativeMethods.GetWindowDC(Msg.HWnd);

            if (hDC == IntPtr.Zero)
            {
                throw new Win32Exception();
            }

            try
            {
                Color backColor = BackColor;

                Color borderColor = this._BorderColor;

                Rectangle bounds = new Rectangle(0, 0, Width, Height);

                using (Graphics g = Graphics.FromHdc(hDC))
                {
                    using (Region region = new Region(bounds))
                    {
                        region.Exclude(AbsoluteClientRectangle);
                        using (Brush brush = new SolidBrush(backColor))
                        {
                            g.FillRegion(brush, region);
                        }
                    }
                    ControlPaint.DrawBorder(
                        g,
                        bounds,
                        borderColor,
                        ButtonBorderStyle.Solid);
                }
            }
            finally
            {
                ListViewNativeMethods.ReleaseDC(Msg.HWnd, hDC);
            }
            Msg.Result = IntPtr.Zero;
        }
Example #2
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="Msg"></param>
            protected override void WndProc(ref Message Msg)
            {
                base.WndProc(ref Msg);

                if (Msg.Msg == 0xF || Msg.Msg == 0x47)
                {
                    IntPtr hdc = ListViewNativeMethods.GetDC(Msg.HWnd);
                    try
                    {
                        using (Graphics g = Graphics.FromHdc(hdc))
                        {
                            Rectangle bounds = this._Owner.HeaderEndRect();

                            Color baseColor = this._Owner.HeadColor;

                            Color borderColor = this._Owner.HeadColor;

                            Color innerBorderColor = Color.FromArgb(150, 255, 255, 255);

                            if (this._Owner.ColumnCount > 0)
                            {
                                bounds.X--;
                                bounds.Width++;
                            }
                            this._Owner.RenderBackgroundInternal(
                                g,
                                bounds,
                                baseColor,
                                borderColor,
                                innerBorderColor,
                                0.45f,
                                true,
                                LinearGradientMode.Vertical);
                        }
                    }
                    finally
                    {
                        ListViewNativeMethods.ReleaseDC(Msg.HWnd, hdc);
                    }
                }
            }