当前位置: 首页>>代码示例>>C#>>正文


C# Region.GetHrgn方法代码示例

本文整理汇总了C#中System.Drawing.Region.GetHrgn方法的典型用法代码示例。如果您正苦于以下问题:C# Region.GetHrgn方法的具体用法?C# Region.GetHrgn怎么用?C# Region.GetHrgn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Region的用法示例。


在下文中一共展示了Region.GetHrgn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawDragOutline

        public static void DrawDragOutline(Region region)
        {
            if (region == null)
                return;

            // Get hold of the DC for the desktop
            IntPtr hDC = User32.GetDC(IntPtr.Zero);

            // Define the area we are allowed to draw into
            IntPtr hRegion = region.GetHrgn(Graphics.FromHdc(hDC));
            Gdi32.SelectClipRgn(hDC, hRegion);

            Win32.RECT rectBox = new Win32.RECT();

            // Get the smallest rectangle that encloses region
            Gdi32.GetClipBox(hDC, ref rectBox);

            IntPtr brushHandler = GetHalfToneBrush();

            // Select brush into the device context
            IntPtr oldHandle = Gdi32.SelectObject(hDC, brushHandler);

            // Blit to screen using provided pattern brush and invert with existing screen contents
            Gdi32.PatBlt(hDC,
                rectBox.left,
                rectBox.top,
                rectBox.right - rectBox.left,
                rectBox.bottom - rectBox.top,
                (uint)Win32.RasterOperations.PATINVERT);

            // Put old handle back again
            Gdi32.SelectObject(hDC, oldHandle);

            // Reset the clipping region
            Gdi32.SelectClipRgn(hDC, IntPtr.Zero);

            Gdi32.DeleteObject(hRegion);

            // Must remember to release the HDC resource!
            User32.ReleaseDC(IntPtr.Zero, hDC);
        }
开发者ID:Longkong,项目名称:Pojjaman,代码行数:41,代码来源:DrawHelper.cs

示例2: cBAreo_CheckStateChanged

 private void cBAreo_CheckStateChanged(object sender, EventArgs e)
 {
     Areo.AreoParams parameter;
     switch (cBAreo.CheckState)
     {
     case CheckState.Checked:
     cBAreo.Text = "窗体背景Areo效果";
     parameter = new Areo.AreoParams();
     parameter.Flags = Areo.AreoParams.ENABLE;       //开启Areo效果
     parameter.Enable = true;                        //开启Areo效果
     parameter.AreoRegion = IntPtr.Zero;             //区域为整个窗体背景区
     Areo.AreoWindow(this.Handle, parameter);        //将整个窗体背景设置为Areo效果
     break;
     case CheckState.Indeterminate:
     cBAreo.Text = "窗体区域Areo效果";
     ClearAreoWindow();                              //清除原有Areo效果
     using (Graphics G = CreateGraphics())
     {
     parameter = new Areo.AreoParams();
     //开启Areo效果和区域Areo效果
     parameter.Flags = Areo.AreoParams.ENABLE | Areo.AreoParams.REGION;
     parameter.Enable = true;                    //开启Areo效果
     Rectangle rect = this.ClientRectangle;
     rect.Inflate(-rect.Width / 4, -rect.Height / 4);
     regionAreo = new Region(rect);              //获取窗体中心区域
     parameter.AreoRegion = regionAreo.GetHrgn(G);//设置Areo区域
     Areo.AreoWindow(this.Handle, parameter);    //将窗体中心区域设置成Areo效果
     }
     break;
     case CheckState.Unchecked:
     cBAreo.Text = "窗体无Areo效果";
     ClearAreoWindow();
     break;
     default:
     break;
     }
     this.Invalidate();
 }
开发者ID:dalinhuang,项目名称:wdeqawes-efrwserd-rgtedrtf,代码行数:38,代码来源:FormAreoRegion.cs

示例3: CreateRegion

 public static void CreateRegion(IntPtr hWnd, int radius, RoundStyle roundStyle, bool redraw)
 {
     Win32.Struct.RECT lpRect = new Win32.Struct.RECT();
     Win32.NativeMethods.GetWindowRect(hWnd, ref lpRect);
     Rectangle rect = new Rectangle(System.Drawing.Point.Empty, lpRect.Size);
     if (roundStyle != RoundStyle.None)
     {
         using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, radius, roundStyle, true))
         {
             using (Region region = new Region(path))
             {
                 path.Widen(Pens.White);
                 region.Union(path);
                 IntPtr windowDC = Win32.NativeMethods.GetWindowDC(hWnd);
                 try
                 {
                     using (Graphics graphics = Graphics.FromHdc(windowDC))
                     {
                         Win32.NativeMethods.SetWindowRgn(hWnd, region.GetHrgn(graphics), redraw);
                     }
                 }
                 finally
                 {
                     Win32.NativeMethods.ReleaseDC(hWnd, windowDC);
                 }
             }
             return;
         }
     }
     IntPtr hRgn = Win32.NativeMethods.CreateRectRgn(0, 0, rect.Width, rect.Height);
     Win32.NativeMethods.SetWindowRgn(hWnd, hRgn, redraw);
 }
开发者ID:jxdong1013,项目名称:archivems,代码行数:32,代码来源:UpdateForm.cs

示例4: SetClipRegion

		internal override void SetClipRegion(IntPtr hwnd, Region region) {
			if (region == null)
				Win32SetWindowRgn (hwnd, IntPtr.Zero, true);
			else
				Win32SetWindowRgn(hwnd, region.GetHrgn(Graphics.FromHwnd(hwnd)), true);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:6,代码来源:XplatUIWin32.cs

示例5: GetMessage


//.........这里部分代码省略.........
					} else {
						if (!hwnd.nc_expose_pending) {
							goto ProcessNextMessage;
						}

						switch (hwnd.border_style) {
							case FormBorderStyle.Fixed3D: {
								Graphics g;

								g = Graphics.FromHwnd(hwnd.whole_window);
								if (hwnd.border_static)
									ControlPaint.DrawBorder3D(g, new Rectangle(0, 0, hwnd.Width, hwnd.Height), Border3DStyle.SunkenOuter);
								else
									ControlPaint.DrawBorder3D(g, new Rectangle(0, 0, hwnd.Width, hwnd.Height), Border3DStyle.Sunken);
								g.Dispose();
								break;
							}

							case FormBorderStyle.FixedSingle: {
								Graphics g;

								g = Graphics.FromHwnd(hwnd.whole_window);
								ControlPaint.DrawBorder(g, new Rectangle(0, 0, hwnd.Width, hwnd.Height), Color.Black, ButtonBorderStyle.Solid);
								g.Dispose();
								break;
							}
						}
						DriverDebug("GetMessage(): Window {0:X} Exposed non-client area {1},{2} {3}x{4}",
							    hwnd.client_window.ToInt32(), xevent.ExposeEvent.x, xevent.ExposeEvent.y,
							    xevent.ExposeEvent.width, xevent.ExposeEvent.height);

						Rectangle rect = new Rectangle (xevent.ExposeEvent.x, xevent.ExposeEvent.y, xevent.ExposeEvent.width, xevent.ExposeEvent.height);
						Region region = new Region (rect);
						IntPtr hrgn = region.GetHrgn (null); // Graphics object isn't needed
						msg.message = Msg.WM_NCPAINT;
						msg.wParam = hrgn == IntPtr.Zero ? (IntPtr)1 : hrgn;
						msg.refobject = region;
						break;
					}
					DriverDebug("GetMessage(): Window {0:X} Exposed area {1},{2} {3}x{4}",
						    hwnd.client_window.ToInt32(), xevent.ExposeEvent.x, xevent.ExposeEvent.y,
						    xevent.ExposeEvent.width, xevent.ExposeEvent.height);
					if (Caret.Visible == true) {
						Caret.Paused = true;
						HideCaret();
					}

					if (Caret.Visible == true) {
						ShowCaret();
						Caret.Paused = false;
					}
					msg.message = Msg.WM_PAINT;
					break;
				}

				case XEventName.DestroyNotify: {

					// This is a bit tricky, we don't receive our own DestroyNotify, we only get those for our children
					hwnd = Hwnd.ObjectFromHandle(xevent.DestroyWindowEvent.window);

					// We may get multiple for the same window, act only one the first (when Hwnd still knows about it)
					if ((hwnd != null) && (hwnd.client_window == xevent.DestroyWindowEvent.window)) {
						CleanupCachedWindows (hwnd);

						DriverDebug("Received X11 Destroy Notification for {0}", XplatUI.Window(hwnd.client_window));
开发者ID:nlhepler,项目名称:mono,代码行数:66,代码来源:XplatUIX11.cs

示例6: HitTestBackground

        public HitTestCode HitTestBackground(Graphics g, Rectangle backgroundRectangle, Region region, Point pt, HitTestOptions options) {
            if (g == null) {
                throw new ArgumentNullException("g");
            }

            IntPtr hRgn = region.GetHrgn(g);

            return HitTestBackground(g, backgroundRectangle, hRgn, pt, options);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:9,代码来源:VisualStyleRenderer.cs

示例7: GetMessage


//.........这里部分代码省略.........
								  xevent.ExposeEvent.x, xevent.ExposeEvent.y,
								  xevent.ExposeEvent.width, xevent.ExposeEvent.height);
#endif
						msg.message = Msg.WM_PAINT;
					}
					else {
						Graphics g;

						switch (hwnd.border_style) {
						case FormBorderStyle.Fixed3D:
							g = Graphics.FromHwnd(hwnd.WholeWindow);
							ControlPaint.DrawBorder3D(g, new Rectangle(0, 0, hwnd.Width, hwnd.Height),
										  Border3DStyle.Sunken);
							g.Dispose();
							break;

						case FormBorderStyle.FixedSingle:
							g = Graphics.FromHwnd(hwnd.WholeWindow);
							ControlPaint.DrawBorder(g, new Rectangle(0, 0, hwnd.Width, hwnd.Height),
										Color.Black, ButtonBorderStyle.Solid);
							g.Dispose();
						break;
						}
#if DriverDebugExtra
						Console.WriteLine("GetMessage(): Window {0:X} Exposed non-client area {1},{2} {3}x{4}",
								  hwnd.ClientWindow.ToInt32(),
								  xevent.ExposeEvent.x, xevent.ExposeEvent.y,
								  xevent.ExposeEvent.width, xevent.ExposeEvent.height);
#endif

						Rectangle rect = new Rectangle (xevent.ExposeEvent.x, xevent.ExposeEvent.y,
										xevent.ExposeEvent.width, xevent.ExposeEvent.height);
						Region region = new Region (rect);
						IntPtr hrgn = region.GetHrgn (null); // Graphics object isn't needed
						msg.message = Msg.WM_NCPAINT;
						msg.wParam = hrgn == IntPtr.Zero ? (IntPtr)1 : hrgn;
						msg.refobject = region;
					}

					return true;
						
				case XEventName.DestroyNotify:

					// This is a bit tricky, we don't receive our own DestroyNotify, we only get those for our children
					hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(xevent.DestroyWindowEvent.window);

					// We may get multiple for the same window, act only one the first (when Hwnd still knows about it)
					if ((hwnd != null) && (hwnd.ClientWindow == xevent.DestroyWindowEvent.window)) {
						CleanupCachedWindows (hwnd);

						#if DriverDebugDestroy
						Console.WriteLine("Received X11 Destroy Notification for {0}", XplatUI.Window(hwnd.ClientWindow));
						#endif

						msg.hwnd = hwnd.ClientWindow;
						msg.message=Msg.WM_DESTROY;
						hwnd.Dispose();
					}
					else
						goto ProcessNextMessage;

					return true;

				case XEventName.ClientMessage:
					if (Dnd.HandleClientMessage (ref xevent))
						goto ProcessNextMessage;
开发者ID:BrzVlad,项目名称:mono,代码行数:67,代码来源:X11Display.cs

示例8: FromRegion

        /// <devdoc>
        ///     Creates a WindowsRegion from a System.Drawing.Region. 
        /// </devdoc>
        public static WindowsRegion FromRegion( Region region, Graphics g ){
            if (region.IsInfinite(g)){
                // An infinite region would cover the entire device region which is the same as
                // not having a clipping region. Observe that this is not the same as having an
                // empty region, which when clipping to it has the effect of excluding the entire
                // device region.
                // To remove the clip region from a dc the SelectClipRgn() function needs to be
                // called with a null region ptr - that's why we use the empty constructor here.
                // GDI+ will return IntPtr.Zero for Region.GetHrgn(Graphics) when the region is
                // Infinite.
                return new WindowsRegion();
            }

            return WindowsRegion.FromHregion(region.GetHrgn(g), true);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:18,代码来源:WindowsRegion.cs

示例9: SetWindowRegion

		protected void SetWindowRegion(Size winSize)
		{
			// Style specific handling
			if (_style == VisualStyle.IDE)
			{
				int shadowHeight = _position[(int)_style, (int)PI.ShadowHeight];
				int shadowWidth = _position[(int)_style, (int)PI.ShadowWidth];

				// Create a new region object
				using (Region drawRegion = new Region())
				{
				// Can draw anywhere
				drawRegion.MakeInfinite();

				// Remove the area above the right hand shadow
				drawRegion.Xor(new Rectangle(winSize.Width - shadowWidth, 0, shadowWidth, shadowHeight));

				// When drawing upwards from a vertical menu we need to allow a connection between the
				// MenuControl selection box and the PopupMenu shadow
				if (!((_direction == Direction.Vertical) && !_excludeTop))
				{
					// Remove the area left of the bottom shadow
					drawRegion.Xor(new Rectangle(0, winSize.Height - shadowHeight, shadowWidth, shadowHeight));
				}

				// Define a region to prevent drawing over exposed corners of shadows
				using(Graphics g = Graphics.FromHwnd(this.Handle))
					WindowsAPI.SetWindowRgn(this.Handle, drawRegion.GetHrgn(g), false);
			}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:31,代码来源:PopupMenu.cs

示例10: Update

            /// <include file='doc\ErrorProvider.uex' path='docs/doc[@for="ErrorProvider.ErrorWindow.Update"]/*' />
            /// <devdoc>
            ///     Move and size the error window, compute and set the window region,
            ///     set the tooltip rectangles and descriptions.  This basically brings
            ///     the error window up to date with the internal data structures.
            /// </devdoc>
            public void Update(bool timerCaused) {
                IconRegion iconRegion = provider.Region;
                Size size = iconRegion.Size;
                windowBounds = Rectangle.Empty;
                for (int i = 0; i < items.Count; i++) {
                    ControlItem item = (ControlItem)items[i];
                    Rectangle iconBounds = item.GetIconBounds(size);
                    if (windowBounds.IsEmpty)
                        windowBounds = iconBounds;
                    else
                        windowBounds = Rectangle.Union(windowBounds, iconBounds);
                }

                Region windowRegion =  new Region(new Rectangle(0, 0, 0, 0));
                IntPtr windowRegionHandle = IntPtr.Zero;
                try {
                    for (int i = 0; i < items.Count; i++) {
                        ControlItem item = (ControlItem)items[i];
                        Rectangle iconBounds = item.GetIconBounds(size);
                        iconBounds.X -= windowBounds.X;
                        iconBounds.Y -= windowBounds.Y;

                        bool showIcon = true;
                        if (!item.ToolTipShown) {
                            switch (provider.BlinkStyle) {
                                case ErrorBlinkStyle.NeverBlink:
                                    // always show icon
                                    break;

                                case ErrorBlinkStyle.BlinkIfDifferentError:
                                    showIcon = (item.BlinkPhase == 0) || (item.BlinkPhase > 0 && (item.BlinkPhase & 1) == (i & 1));
                                    break;

                                case ErrorBlinkStyle.AlwaysBlink:
                                    showIcon = ((i & 1) == 0) == provider.showIcon;
                                    break;
                            }
                        }

                        if (showIcon)
                        {
                            iconRegion.Region.Translate(iconBounds.X, iconBounds.Y);
                            windowRegion.Union(iconRegion.Region);
                            iconRegion.Region.Translate(-iconBounds.X, -iconBounds.Y);
                        }

                        if (tipWindow != null) {
                            NativeMethods.TOOLINFO_T toolInfo = new NativeMethods.TOOLINFO_T();
                            toolInfo.cbSize = Marshal.SizeOf(toolInfo);
                            toolInfo.hwnd = Handle;
                            toolInfo.uId = item.Id;
                            toolInfo.lpszText = item.Error;
                            toolInfo.rect = NativeMethods.RECT.FromXYWH(iconBounds.X, iconBounds.Y, iconBounds.Width, iconBounds.Height);
                            toolInfo.uFlags = NativeMethods.TTF_SUBCLASS;
                            if (provider.RightToLeft) {
                                toolInfo.uFlags |= NativeMethods.TTF_RTLREADING;
                            }
                            UnsafeNativeMethods.SendMessage(new HandleRef(tipWindow, tipWindow.Handle), NativeMethods.TTM_SETTOOLINFO, 0, toolInfo);
                        }

                        if (timerCaused && item.BlinkPhase > 0) {
                            item.BlinkPhase--;
                        }
                    }
                    if (timerCaused) {
                        provider.showIcon = !provider.showIcon;
                    }


                    DeviceContext dc = null;
                    dc = DeviceContext.FromHwnd(this.Handle);
                    try {
                        CreateMirrorDC(dc.Hdc, windowBounds.Width);
                        
                        Graphics graphics = Graphics.FromHdcInternal(mirrordc.Hdc);
                        try {
                            windowRegionHandle = windowRegion.GetHrgn(graphics);
                            System.Internal.HandleCollector.Add(windowRegionHandle, NativeMethods.CommonHandles.GDI);
                        }
                        finally {
                            graphics.Dispose();
                            RestoreMirrorDC();
                        }
                        
                        if (UnsafeNativeMethods.SetWindowRgn(new HandleRef(this, Handle), new HandleRef(windowRegion, windowRegionHandle), true) != 0) {
                            //The HWnd owns the region.
                            windowRegionHandle = IntPtr.Zero;
                        }
                    }
                    
                    finally {
                        if (dc != null) {
                            dc.Dispose();
                        }
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:ErrorProvider.cs

示例11: NcPaint

        /// <summary>
        /// Redraws the non client area.
        /// </summary>
        /// <param name="invalidateBuffer">if set to <c>true</c> the buffer is invalidated.</param>
        /// <returns>true if the original painting should be suppressed otherwise false.</returns>
        private bool NcPaint(bool invalidateBuffer)
        {
            if (!IsProcessNcArea)
                return false;
            bool result = false;

            IntPtr hdc = (IntPtr)0;
            Graphics g = null;
            Region region = null;
            IntPtr hrgn = (IntPtr)0;

            try
            {
                // no drawing needed
                if (_parentForm.MdiParent != null && _parentForm.WindowState == FormWindowState.Maximized)
                {
                    _currentCacheSize = Size.Empty;
                    return false;
                }

                // prepare image bounds
                Size borderSize = FormExtenders.GetBorderSize(_parentForm);
                int captionHeight = FormExtenders.GetCaptionHeight(_parentForm);

                RECT rectScreen = new RECT();
                Win32Api.GetWindowRect(_parentForm.Handle, ref rectScreen);

                Rectangle rectBounds = rectScreen.ToRectangle();
                rectBounds.Offset(-rectBounds.X, -rectBounds.Y);

                // prepare clipping
                Rectangle rectClip = rectBounds;
                region = new Region(rectClip);
                rectClip.Inflate(-borderSize.Width, -borderSize.Height);
                rectClip.Y += captionHeight;
                rectClip.Height -= captionHeight;

                // create graphics handle
                hdc = Win32Api.GetDCEx(_parentForm.Handle, (IntPtr)0,
                    (DCXFlags.DCX_CACHE | DCXFlags.DCX_CLIPSIBLINGS | DCXFlags.DCX_WINDOW));
                g = Graphics.FromHdc(hdc);

                // Apply clipping
                region.Exclude(rectClip);
                hrgn = region.GetHrgn(g);
                Win32Api.SelectClipRgn(hdc, hrgn);

                // create new buffered graphics if needed
                if (_bufferGraphics == null || _currentCacheSize != rectBounds.Size)
                {
                    if (_bufferGraphics != null)
                        _bufferGraphics.Dispose();

                    _bufferGraphics = _bufferContext.Allocate(g, new Rectangle(0, 0,
                                rectBounds.Width, rectBounds.Height));
                    _currentCacheSize = rectBounds.Size;
                    invalidateBuffer = true;
                }

                if (invalidateBuffer)
                {
                    // Create painting meta data for form
                    SkinningFormPaintData paintData = new SkinningFormPaintData(_bufferGraphics.Graphics, rectBounds)
                    {
                        Borders = borderSize,
                        CaptionHeight = captionHeight,
                        Active = _formIsActive,
                        HasMenu = FormExtenders.HasMenu(_parentForm),
                        IconSize = SystemInformation.SmallIconSize,
                        IsSmallCaption =
                            captionHeight ==
                            SystemInformation.ToolWindowCaptionHeight,
                        Text = _parentForm.Text
                    };

                    // create painting meta data for caption buttons
                    if (_captionButtons.Count > 0)
                    {
                        paintData.CaptionButtons = new CaptionButtonPaintData[_captionButtons.Count];
                        for (int i = 0; i < _captionButtons.Count; i++)
                        {
                            CaptionButton button = _captionButtons[i];
                            CaptionButtonPaintData buttonData = new CaptionButtonPaintData(_bufferGraphics.Graphics, button.Bounds)
                            {
                                Pressed = button.Pressed,
                                Hovered = button.Hovered,
                                Enabled = button.Enabled,
                                HitTest = button.HitTest
                            };
                            paintData.CaptionButtons[i] = buttonData;
                        }
                    }

                    // paint
                    result = _manager.CurrentSkin.OnNcPaint(_parentForm, paintData);
//.........这里部分代码省略.........
开发者ID:galek,项目名称:SkinFramework,代码行数:101,代码来源:SkinningForm.cs

示例12: Update

            public void Update(bool timerCaused)
            {
                ErrorProvider.IconRegion region = this.provider.Region;
                Size size = region.Size;
                this.windowBounds = Rectangle.Empty;
                for (int i = 0; i < this.items.Count; i++)
                {
                    Rectangle iconBounds = ((ErrorProvider.ControlItem) this.items[i]).GetIconBounds(size);
                    if (this.windowBounds.IsEmpty)
                    {
                        this.windowBounds = iconBounds;
                    }
                    else
                    {
                        this.windowBounds = Rectangle.Union(this.windowBounds, iconBounds);
                    }
                }
                Region wrapper = new Region(new Rectangle(0, 0, 0, 0));
                IntPtr zero = IntPtr.Zero;
                try
                {
                    for (int j = 0; j < this.items.Count; j++)
                    {
                        ErrorProvider.ControlItem item2 = (ErrorProvider.ControlItem) this.items[j];
                        Rectangle rectangle2 = item2.GetIconBounds(size);
                        rectangle2.X -= this.windowBounds.X;
                        rectangle2.Y -= this.windowBounds.Y;
                        bool flag = true;
                        if (!item2.ToolTipShown)
                        {
                            switch (this.provider.BlinkStyle)
                            {
                                case ErrorBlinkStyle.BlinkIfDifferentError:
                                    flag = (item2.BlinkPhase == 0) || ((item2.BlinkPhase > 0) && ((item2.BlinkPhase & 1) == (j & 1)));
                                    break;

                                case ErrorBlinkStyle.AlwaysBlink:
                                    flag = ((j & 1) == 0) == this.provider.showIcon;
                                    break;
                            }
                        }
                        if (flag)
                        {
                            region.Region.Translate(rectangle2.X, rectangle2.Y);
                            wrapper.Union(region.Region);
                            region.Region.Translate(-rectangle2.X, -rectangle2.Y);
                        }
                        if (this.tipWindow != null)
                        {
                            System.Windows.Forms.NativeMethods.TOOLINFO_T toolinfo_t;
                            toolinfo_t = new System.Windows.Forms.NativeMethods.TOOLINFO_T {
                                cbSize = Marshal.SizeOf(toolinfo_t),
                                hwnd = base.Handle,
                                uId = item2.Id,
                                lpszText = item2.Error,
                                rect = System.Windows.Forms.NativeMethods.RECT.FromXYWH(rectangle2.X, rectangle2.Y, rectangle2.Width, rectangle2.Height),
                                uFlags = 0x10
                            };
                            if (this.provider.RightToLeft)
                            {
                                toolinfo_t.uFlags |= 4;
                            }
                            System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this.tipWindow, this.tipWindow.Handle), System.Windows.Forms.NativeMethods.TTM_SETTOOLINFO, 0, toolinfo_t);
                        }
                        if (timerCaused && (item2.BlinkPhase > 0))
                        {
                            item2.BlinkPhase--;
                        }
                    }
                    if (timerCaused)
                    {
                        this.provider.showIcon = !this.provider.showIcon;
                    }
                    DeviceContext context = null;
                    using (context = DeviceContext.FromHwnd(base.Handle))
                    {
                        this.CreateMirrorDC(context.Hdc, this.windowBounds.Width);
                        Graphics g = Graphics.FromHdcInternal(this.mirrordc.Hdc);
                        try
                        {
                            zero = wrapper.GetHrgn(g);
                            System.Internal.HandleCollector.Add(zero, System.Windows.Forms.NativeMethods.CommonHandles.GDI);
                        }
                        finally
                        {
                            g.Dispose();
                            this.RestoreMirrorDC();
                        }
                        if (System.Windows.Forms.UnsafeNativeMethods.SetWindowRgn(new HandleRef(this, base.Handle), new HandleRef(wrapper, zero), true) != 0)
                        {
                            zero = IntPtr.Zero;
                        }
                    }
                }
                finally
                {
                    wrapper.Dispose();
                    if (zero != IntPtr.Zero)
                    {
                        System.Windows.Forms.SafeNativeMethods.DeleteObject(new HandleRef(null, zero));
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ErrorProvider.cs

示例13: GetHrgn_Infinite_MakeEmpty

		public void GetHrgn_Infinite_MakeEmpty ()
		{
			Region r = new Region ();
			Assert.IsFalse (r.IsEmpty (graphic), "!Empty");
			Assert.IsTrue (r.IsInfinite (graphic), "Infinite");
			Assert.AreEqual (IntPtr.Zero, r.GetHrgn (graphic), "Handle==0");

			r.MakeEmpty ();
			Assert.IsTrue (r.IsEmpty (graphic), "Empty");
			Assert.IsFalse (r.IsInfinite (graphic), "!Infinite");
			IntPtr h = r.GetHrgn (graphic);
			Assert.IsFalse (h == IntPtr.Zero, "Handle!=0");
#if NET_2_0
			r.ReleaseHrgn (h);
#endif
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:16,代码来源:TestRegion.cs

示例14: NCPaint

        private void NCPaint()
        {
            if (this.Parent == null)
                return;
            if (this.Width <= 0 || this.Height <= 0)
                return;

            IntPtr windowDC = NativeMethods.GetDCEx(this.Handle,
                             IntPtr.Zero, NativeMethods.DCX_CACHE |
                             NativeMethods.DCX_WINDOW |
                             NativeMethods.DCX_CLIPSIBLINGS |
                             NativeMethods.DCX_LOCKWINDOWUPDATE);

            if (windowDC.Equals(IntPtr.Zero))
                return;

            using (Bitmap bm = new Bitmap(this.Width, this.Height,
                System.Drawing.Imaging.PixelFormat.Format32bppPArgb))
            {

                using (Graphics g = Graphics.FromImage(bm))
                {

                    Rectangle borderRect = new Rectangle(0, 0,
                        Width - 1, Height - 1);

                    using (Pen borderPen = new Pen(this.borderColor, 1))
                    {
                        borderPen.Alignment = PenAlignment.Inset;
                        g.DrawRectangle(borderPen, borderRect);
                    }

                    // Create and Apply a Clip Region to the WindowDC
                    using (Region Rgn = new Region(new
                        Rectangle(0, 0, Width, Height)))
                    {
                        Rgn.Exclude(new Rectangle(1, 1, Width - 2, Height - 2));
                        IntPtr hRgn = Rgn.GetHrgn(g);
                        if (!hRgn.Equals(IntPtr.Zero))
                            NativeMethods.SelectClipRgn(windowDC, hRgn);

                        IntPtr bmDC = g.GetHdc();
                        IntPtr hBmp = bm.GetHbitmap();
                        IntPtr oldDC = NativeMethods.SelectObject(bmDC,
                            hBmp);
                        NativeMethods.BitBlt(windowDC, 0, 0, bm.Width,
                            bm.Height, bmDC, 0, 0, NativeMethods.SRCCOPY);

                        NativeMethods.SelectClipRgn(windowDC, IntPtr.Zero);
                        NativeMethods.DeleteObject(hRgn);

                        g.ReleaseHdc(bmDC);
                        NativeMethods.SelectObject(oldDC, hBmp);
                        NativeMethods.DeleteObject(hBmp);
                        bm.Dispose();
                    }
                }
            }

            NativeMethods.ReleaseDC(this.Handle, windowDC);

        }
开发者ID:huizh,项目名称:xenadmin,代码行数:62,代码来源:BlueBorderPanel.cs

示例15: GetHRegion

        private IntPtr GetHRegion()
        {
            //Define a Clip Region to pass back to WM_NCPAINTs wParam.
            //Must be in Screen Coordinates.
            IntPtr hRgn;
            Rectangle winRect = this.Parent.RectangleToScreen(this.Bounds);
            Rectangle clientRect =
                this.RectangleToScreen(this.ClientRectangle);

            Region updateRegion = new Region(winRect);
            updateRegion.Complement(clientRect);

            using (Graphics g = this.CreateGraphics())
                hRgn = updateRegion.GetHrgn(g);
            updateRegion.Dispose();
            return hRgn;
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:17,代码来源:BlueBorderPanel.cs


注:本文中的System.Drawing.Region.GetHrgn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。