Ejemplo n.º 1
0
        private void CreatePen()
        {
            if (width > 1)    // Geometric pen.
            {
                // From MSDN: if width > 1, the style must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME.
                style |= WindowsPenStyle.Geometric | WindowsPenStyle.Solid;
            }

            if (wndBrush == null)
            {
                nativeHandle = IntSafeNativeMethods.CreatePen((int)style, width, ColorTranslator.ToWin32(color));
            }
            else
            {
                IntNativeMethods.LOGBRUSH lb = new IntNativeMethods.LOGBRUSH
                {
                    lbColor = ColorTranslator.ToWin32(wndBrush.Color),
                    lbStyle = IntNativeMethods.BS_SOLID,
                    lbHatch = 0
                };

                // Note: We currently don't support custom styles, that's why 0 and null for last two params.
                nativeHandle = IntSafeNativeMethods.ExtCreatePen((int)style, width, lb, 0, null);
            }
        }
Ejemplo n.º 2
0
        protected override void CreateBrush()
        { 
            IntPtr nativeHandle = IntSafeNativeMethods.CreateSolidBrush(ColorTranslator.ToWin32( this.Color));
            if(nativeHandle == IntPtr.Zero) // Don't use Debug.Assert, DbgUtil.GetLastErrorStr would always be evaluated.
            {
                Debug.Fail("CreateSolidBrush failed : " + DbgUtil.GetLastErrorStr());
            }

            this.NativeHandle = nativeHandle;  // sets the handle value in the base class.
        }
Ejemplo n.º 3
0
        private void CreatePen()
        {
            if (this.width > 1)    // Geometric pen.
            {
                // From MSDN: if width > 1, the style must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME.
                this.style |= WindowsPenStyle.Geometric | WindowsPenStyle.Solid;
            }

            if (this.wndBrush == null)
            {
                this.nativeHandle = IntSafeNativeMethods.CreatePen((int)this.style, this.width, ColorTranslator.ToWin32(this.color));
            }
            else
            {
                IntNativeMethods.LOGBRUSH lb = new IntNativeMethods.LOGBRUSH();

                lb.lbColor = ColorTranslator.ToWin32(this.wndBrush.Color);
                lb.lbStyle = IntNativeMethods.BS_SOLID;
                lb.lbHatch = 0; // CONSIDER: Check if HatchBrush and get the style if so (If needed in the future).

                // Note: We currently don't support custom styles, that's why 0 and null for last two params.
                this.nativeHandle = IntSafeNativeMethods.ExtCreatePen((int)this.style, this.width, lb, 0, null);
            }
        }
Ejemplo n.º 4
0
        /// <devdoc>
        /// </devdoc>


        private void CreateRegion(Rectangle rect)
        {
            Debug.Assert(nativeHandle == IntPtr.Zero, "nativeHandle should be null, we're leaking handle");
            this.nativeHandle = IntSafeNativeMethods.CreateRectRgn(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
            ownHandle         = true;
        }