示例#1
0
        protected override void CreateBrush()
        {
            IntPtr nativeHandle = Gdi32.CreateSolidBrush(ColorTranslator.ToWin32(Color));

            Debug.Assert(nativeHandle != IntPtr.Zero);
            HBrush = nativeHandle;
        }
示例#2
0
        protected override void CreateBrush()
        {
            IntPtr nativeHandle = Gdi32.CreateSolidBrush(ColorTranslator.ToWin32(Color));

            // Don't use Debug.Assert, DbgUtil.GetLastErrorStr would always be evaluated.
            if (nativeHandle == IntPtr.Zero)
            {
                Debug.Fail("CreateSolidBrush failed : " + DbgUtil.GetLastErrorStr());
            }

            HBrush = nativeHandle;
        }
示例#3
0
        private void DrawNCArea(IntPtr hRgn)
        {
            Region clipRegion = null;

            if (hRgn != TRUE)
            {
                clipRegion = Region.FromHrgn(hRgn);
            }

            RECT windowRect  = new RECT();
            RECT nclientRect = new RECT();
            RECT clientRect  = new RECT();


            User32.GetWindowRect(parentWindowHWnd, ref windowRect);
            User32.OffsetRect(ref windowRect, -windowRect.left, -windowRect.top);

            var height = windowRect.bottom;
            var width  = windowRect.right;


            User32.GetClientRect(parentWindowHWnd, ref clientRect);
            User32.OffsetRect(ref clientRect, -clientRect.left, -clientRect.top);

            User32.GetClientRect(parentWindowHWnd, ref nclientRect);

            User32.OffsetRect(ref nclientRect, -clientRect.left, -clientRect.top);
            User32.OffsetRect(ref nclientRect, borderSize, borderSize);


            IntPtr hDC = User32.GetWindowDC(parentWindowHWnd);

            var windowRectangle = new Rectangle(windowRect.left, windowRect.top, (int)windowRect.Width, (int)windowRect.Height);
            var clientRectangle = new Rectangle(nclientRect.left, nclientRect.top, (int)clientRect.Height, (int)clientRect.Width);



            try
            {
                COLORREF color  = new COLORREF(borderColor);
                IntPtr   hBrush = Gdi32.CreateSolidBrush(color.ColorDWORD);
                Gdi32.ExcludeClipRect(hDC, nclientRect.left, nclientRect.top, nclientRect.right, nclientRect.bottom);
                User32.FillRect(hDC, ref windowRect, hBrush);
                Gdi32.DeleteObject(hBrush);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                User32.ReleaseDC(parentWindowHWnd, hDC);
            }
        }
 protected override void CreateBrush()
 {
     Gdi32.HBRUSH nativeHandle = Gdi32.CreateSolidBrush(ColorTranslator.ToWin32(Color));
     Debug.Assert(!nativeHandle.IsNull);
     HBrush = nativeHandle;
 }
示例#5
0
        private void DrawNCArea(IntPtr hRgn)
        {
            Region clipRegion = null;

            if (hRgn != TRUE)
            {
                clipRegion = Region.FromHrgn(hRgn);
            }

            RECT windowRect = new RECT();

            RECT clientRect = new RECT();


            User32.GetWindowRect(parentWindowHWnd, ref windowRect);
            User32.OffsetRect(ref windowRect, -windowRect.left, -windowRect.top);

            var height = windowRect.bottom;
            var width  = windowRect.right;

            if (Win_Height == height && Win_Width == width)
            {
                return;
            }

            Win_Height = height;
            Win_Width  = width;



            User32.GetClientRect(parentWindowHWnd, ref clientRect);
            User32.OffsetRect(ref clientRect, -clientRect.left, -clientRect.top);

            User32.OffsetRect(ref clientRect, borderSize, borderSize);


            IntPtr hDC = User32.GetWindowDC(parentWindowHWnd);



            COLORREF color = new COLORREF(borderColor);



            try
            {
                IntPtr hBrush = Gdi32.CreateSolidBrush(color.ColorDWORD);
                Gdi32.ExcludeClipRect(hDC, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom);

                User32.FillRect(hDC, ref windowRect, hBrush);

                //var topRect = new RECT(0, 0, (int)windowRect.Width, borderSize);
                //var bottomRect = new RECT(0, (int)windowRect.Height - borderSize, (int)windowRect.Width, borderSize);
                //var leftRect = new RECT(0, borderSize, borderSize, (int)windowRect.Height - borderSize * 2);
                //var rightRect = new RECT((int)windowRect.Width - borderSize, borderSize, borderSize, (int)windowRect.Height - borderSize * 2);

                //User32.FillRect(hDC, ref topRect, hBrush);
                //User32.FillRect(hDC, ref bottomRect, hBrush);
                //User32.FillRect(hDC, ref leftRect, hBrush);
                //User32.FillRect(hDC, ref rightRect, hBrush);

                Gdi32.DeleteObject(hBrush);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                User32.ReleaseDC(parentWindowHWnd, hDC);
            }
        }