• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RECT类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RECT的典型用法代码示例。如果您正苦于以下问题:C# RECT类的具体用法?C# RECT怎么用?C# RECT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RECT类属于命名空间,在下文中一共展示了RECT类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetWindowRectangle

        public static RECT GetWindowRectangle(IntPtr windowHandle)
        {
            RECT ret = new RECT();
            GetWindowRect(windowHandle, out ret);

            return ret;
        }
开发者ID:dremin,项目名称:cairoshell,代码行数:7,代码来源:NativeMethods.cs


示例2: UIWindow

 protected UIWindow(string title, RECT frame)
 {
     fTitle = title;
     fFrame = frame;
     fBounds = new RECT(0, 0, frame.Width, frame.Height);
     fSurfaceID = MetaSpace.CreateSurface(title, frame, new OnSurfaceCreatedEventHandler(OnSurfaceCreated));
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:7,代码来源:UIWindow.cs


示例3: TmrCursor_Tick

        private static void TmrCursor_Tick(object sender, EventArgs e)
        {
            try {
                Process[] processes = Process.GetProcesses();

                foreach (var p in processes)
                {
                    if (p.ProcessName == "devenv" || p.ProcessName == "notepad") {
                        Point pos = Cursor.Position;
                        IntPtr handle = p.MainWindowHandle;
                        var rectangle = new RECT();

                        if (!GetWindowRect(handle, ref rectangle)) continue;
                        var rnd = new Random();
                        Cursor.Position = new Point(rnd.Next(0, rectangle.Width), rnd.Next(0, rectangle.Height));

                        mouse_event(MouseeventfLeftdown | MouseeventfLeftup, Cursor.Position.X, Cursor.Position.Y, 0, 0);
                        Cursor.Position = pos;
                    }
                }
            }
            catch {
                // ignored
            }
        }
开发者ID:ertseyhan,项目名称:Adana-cCc,代码行数:25,代码来源:frmMain.cs


示例4: GradientRect

        public GradientRect(int left, int top, int width, int height, Colorref startColor, Colorref endColor, GradientRectDirection style)
        {
            fRect = new RECT(left, top, width, height);

            fVertices = new TRIVERTEX[2];
            fGradientRect = new GRADIENT_RECT[1];

            fGradientRect[0] = new GRADIENT_RECT();

            SetVertices(left, top, width, height);

            // Set Colors for left/top
            fVertices[0].Red = startColor.Red16;
            fVertices[0].Green = startColor.Green16;
            fVertices[0].Blue = startColor.Blue16;
            fVertices[0].Alpha = 0x0000;

            // Set Colors for right/bottom
            fVertices[1].Red = endColor.Red16;
            fVertices[1].Green = endColor.Green16;
            fVertices[1].Blue = endColor.Blue16;
            fVertices[1].Alpha = 0x0000;

            fGradientRect[0].UpperLeft = 0;
            fGradientRect[0].LowerRight = 1;

            fGradientDirection = style;
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:28,代码来源:GradientRect.cs


示例5: SyncWindowSize

        private void SyncWindowSize(bool log)
        {
            try
            {
                RECT rect = new RECT();
                NativeWindowMethods.GetWindowRect(_windowHandle, ref rect);

                var width = rect.Right - rect.Left;
                var height = rect.Bottom - rect.Top;

                if (log)
                {
                    _logger.Info("SyncWindowSize Top={0} Left={1} Width={2} Height={3}", rect.Top, rect.Left, width, height);
                }

                _form.InvokeIfRequired(() =>
                {
                    if (_form.WindowState == FormWindowState.Normal)
                    {
                        _form.Top = rect.Top;
                        _form.Left = rect.Left;
                        _form.Width = rect.Right - rect.Left;
                        _form.Height = rect.Bottom - rect.Top;
                    }
                });
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error syncing window positions", ex);
            }
        }
开发者ID:kabellrics,项目名称:Emby.Theater.Windows,代码行数:31,代码来源:WindowSync.cs


示例6: CaptureWindow

        public static Image CaptureWindow(IntPtr handle)
        {

            IntPtr hdcSrc = User32.GetWindowDC(handle);

            RECT windowRect = new RECT();
            User32.GetWindowRect(handle, ref windowRect);

            int width = windowRect.right - windowRect.left;
            int height = windowRect.bottom - windowRect.top;

            IntPtr hdcDest = Gdi32.CreateCompatibleDC(hdcSrc);
            IntPtr hBitmap = Gdi32.CreateCompatibleBitmap(hdcSrc, width, height);

            IntPtr hOld = Gdi32.SelectObject(hdcDest, hBitmap);
            Gdi32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY);
            Gdi32.SelectObject(hdcDest, hOld);
            Gdi32.DeleteDC(hdcDest);
            User32.ReleaseDC(handle, hdcSrc);

            Image image = Image.FromHbitmap(hBitmap);
            Gdi32.DeleteObject(hBitmap);

            return image;
        }
开发者ID:sj-ko,项目名称:gbu_gaenari_monitor,代码行数:25,代码来源:ImageCapture.cs


示例7: GetBandRect

 public Rectangle GetBandRect(int bandIndex)
 {
     RECT rect = new RECT();
     //int index = GetBandActualIndex(bandIndex);
     WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_GETRECT, bandIndex, ref rect);
     return new Rectangle(rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
 }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:7,代码来源:Rebar.cs


示例8: Capture

        public static Bitmap Capture(RECT rect)
        {
            int width = rect.Right - rect.Left;
            int height = rect.Bottom - rect.Top;
            try
            {
                var bitmap = new Bitmap(width, height);
                Graphics g = Graphics.FromImage(bitmap);
                g.CopyFromScreen(new Point(rect.Left, rect.Top), new Point(0, 0),
                    new Size(width, height));

                IntPtr dc = g.GetHdc();
                g.ReleaseHdc(dc);

                //            bitmap.Save(Path + "\\" + GenerateFileName() + ".png", ImageFormat.Png);
                //Console.WriteLine("Captured");

                //g.Clear(Color.Transparent);
                return bitmap;
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:ZhuGongpu,项目名称:CloudX,代码行数:25,代码来源:WindowCaptureUtility.cs


示例9: CheckBounds

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hWnd">被覆盖控件句柄。</param>
        internal void CheckBounds(IntPtr hWnd)
        {
            RECT controlRect = new RECT();
            RECT maskRect = new RECT();

            NativeMethods.GetWindowRect(base.Handle, ref maskRect);
            NativeMethods.GetWindowRect(hWnd, ref controlRect);

            uint uFlag =
                SWP.SWP_NOACTIVATE |
                SWP.SWP_NOOWNERZORDER |
                SWP.SWP_NOZORDER;

            if (!NativeMethods.EqualRect(ref controlRect, ref maskRect))
            {
                Point point = new Point(controlRect.Left, controlRect.Top);
                IntPtr hParent = NativeMethods.GetParent(base.Handle);
                NativeMethods.ScreenToClient(hParent, ref point);

                NativeMethods.SetWindowPos(
                    base.Handle,
                    IntPtr.Zero,
                    point.X,
                    point.Y,
                    controlRect.Right - controlRect.Left,
                    controlRect.Bottom - controlRect.Top,
                    uFlag);
            }
        }
开发者ID:songques,项目名称:CSSIM_Solution,代码行数:33,代码来源:MaskControlBase.cs


示例10: RemoveBorder

        public static void RemoveBorder(IntPtr hwnd)
        {
            const int SWP_FRAMECHANGED = 0x0020;
            const int GWL_STYLE = -16;
            const int GWL_EXSTYLE = -20;
            const int WS_SYSMENU = 524288;
            const int WS_THICKFRAME = 262144;
            const int WS_MINIMIZE = 536870912;
            const int WS_MAXIMIZE = 16777216;
            const int WS_BORDER = 8388608;
            const int WS_DLGFRAME = 4194304;
            const int WS_CAPTION = WS_BORDER | WS_DLGFRAME;
            const int WS_EX_DLGMODALFRAME = 1;
            const int WS_EX_CLIENTEDGE = 512;
            const int WS_EX_STATICEDGE = 131072;

            var style = GetWindowLong(hwnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
            SetWindowLong(hwnd, GWL_STYLE, style);

            var exst = GetWindowLong(hwnd, GWL_EXSTYLE) & ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
            SetWindowLong(hwnd, GWL_EXSTYLE, exst);

            var rect = new RECT();
            var ok = GetWindowRect(hwnd, out rect)
                  && SetWindowPos(hwnd, 0, rect.X, rect.Y, rect.Width, rect.Height, SWP_FRAMECHANGED);
            if (!ok)
                throw new Exception("Error, can't remove border apparently.");
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:28,代码来源:Interop.cs


示例11: CreateSurface

        public static UISurface CreateSurface(string title, RECT frame, Guid uniqueID)
        {
            UISurface newSurface = new UISurface(title, frame, uniqueID);
            newSurface.ClearToColor(RGBColor.LtGray);

            return newSurface;
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:7,代码来源:UISurface.cs


示例12: FindWindow

 /// <summary>
 /// 根据窗口标题获取窗口的大小和位置(当多个标题相同的窗体存在时,默认获取上一个活动的窗体)
 /// </summary>
 /// <param name="WindowTitle">窗口标题(字符串不能有任何差别)</param>
 /// <returns>窗口的大小和位置(System.Drawing.Rectangle)</returns>
 public static System.Drawing.Rectangle FindWindow(string WindowTitle)
 {
     RECT rect = new RECT();
     string lpClassName = null;
     GetWindowRect(FindWindow(lpClassName, WindowTitle), ref rect);
     return new System.Drawing.Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
 }
开发者ID:yanyuzhy,项目名称:LolAutoPlay,代码行数:12,代码来源:My.cs


示例13: GradientRect

        public GradientRect(int left, int top, int width, int height, uint startColor, uint endColor, GradientRectDirection style)
        {
            fRect = new RECT(left, top, width, height);

            fVertices = new TRIVERTEX[2];
            fGradientRect = new GRADIENT_RECT[1];

            fGradientRect[0] = new GRADIENT_RECT();

            SetVertices(left, top, width, height);

            // Set Colors for left/top
            fVertices[0].Red = (ushort)(RGBColor.R(startColor) << 8);
            fVertices[0].Green = (ushort)(RGBColor.G(startColor) << 8);
            fVertices[0].Blue = (ushort)(RGBColor.B(startColor) << 8);
            fVertices[0].Alpha = 0x0000;

            // Set Colors for right/bottom
            fVertices[1].Red = (ushort)(RGBColor.R(endColor) << 8);
            fVertices[1].Green = (ushort)(RGBColor.G(endColor) << 8);
            fVertices[1].Blue = (ushort)(RGBColor.B(endColor) << 8);
            fVertices[1].Alpha = 0x0000;

            fGradientRect[0].UpperLeft = 0;
            fGradientRect[0].LowerRight = 1;

            fGradientDirection = style;
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:28,代码来源:GradientRect.cs


示例14: Pencil

 public Pencil(uint colorref)
 {
     fColor = colorref;
     //fPen = new Pen(Guid.NewGuid(), colorref, PenStyle.Solid, PenType.Cosmetic, PenJoinStyle.Round, PenEndCap.Round, 1);
     fPen = new CosmeticPen(PenStyle.Solid, fColor, Guid.NewGuid());
     fDrawingBounds = RECT.Empty;
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:7,代码来源:Pencil.cs


示例15: PrintWindow

        public static Bitmap PrintWindow(IntPtr hwnd)
        {
            RECT rc = new RECT();
            User32.GetWindowRect(hwnd, ref rc);

            Bitmap bmp = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
            Graphics gfxBmp = Graphics.FromImage(bmp);
            IntPtr hdcBitmap = gfxBmp.GetHdc();
            bool succeeded = User32.PrintWindow(hwnd, hdcBitmap, 0);
            gfxBmp.ReleaseHdc(hdcBitmap);
            if (!succeeded)
            {
                gfxBmp.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(Point.Empty, bmp.Size));
            }
            IntPtr hRgn = Gdi32.CreateRectRgn(0, 0, 0, 0);
            User32.GetWindowRgn(hwnd, hRgn);
            Region region = Region.FromHrgn(hRgn);
            if (!region.IsEmpty(gfxBmp))
            {
                gfxBmp.ExcludeClip(region);
                gfxBmp.Clear(Color.Transparent);
            }
            gfxBmp.Dispose();
            return bmp;
        }
开发者ID:grozeille,项目名称:WebPaparazzi,代码行数:25,代码来源:Utilities.cs


示例16: CaptureScreen

        /// <summary>
        /// Снятие скриншота окна
        /// </summary>
        /// <returns>Скрин или null в случае неудачи</returns>
        public Bitmap CaptureScreen()
        {
            if (Handle == IntPtr.Zero) return null;
            RECT windowRect = new RECT();
            GetWindowRect(Handle, ref windowRect);
            var Left = windowRect.left + config.xOffset;
            var Top = windowRect.top + config.yOffset;

            int h = windowRect.right - Left;
            int w = windowRect.bottom - Top;

            if (h > config.maxHeight) h = config.maxHeight;
            if (w > config.maxWidth) w = config.maxWidth;

            Bitmap BMP = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            System.Drawing.Graphics GFX = System.Drawing.Graphics.FromImage(BMP);
            IntPtr del = GFX.GetHdc();
            IntPtr dc2 = GetWindowDC(Handle);
             //CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt
            BitBlt(del, 0, 0, BMP.Width, BMP.Height, dc2, config.xOffset, config.yOffset, (int)(CopyPixelOperation.SourceCopy | CopyPixelOperation.CaptureBlt));
            GFX.ReleaseHdc(del);
            ReleaseDC(Handle, dc2);

            return BMP;
        }
开发者ID:PakosChivaldori,项目名称:KMine,代码行数:30,代码来源:Window.cs


示例17: GetWindowSize

		private Dictionary<string, int> GetWindowSize(string processName)
		{
			IntPtr handle = IntPtr.Zero;
			foreach (Process process in Process.GetProcesses())
			{


				if (process.MainWindowTitle.IndexOf(processName) >= 0)
				{
					handle = process.MainWindowHandle;
				}
			}
			if (handle == IntPtr.Zero)
				throw new WindowNotFoundException();

			RECT rect = new RECT(); POINT point = new POINT();
			GetClientRect(handle, out rect);
			ClientToScreen(handle, out point);
			var result = new Dictionary<string, int>();
			result.Add("width", (int)(rect.right - rect.left));
			result.Add("height", (int)(rect.bottom - rect.top));
			result.Add("x", (int)point.x);
			result.Add("y", (int)point.y);
			return result;
		}
开发者ID:mok-aster,项目名称:NasneCapture,代码行数:25,代码来源:WIndowCapture.cs


示例18: OnCreateSurface

        public virtual void OnCreateSurface(string title, RECT frame, Guid uniqueID)
        {
            if (null != OnCreateSurfaceEvent)
                OnCreateSurfaceEvent(title, frame, uniqueID);

            OnSurfaceCreated(uniqueID);
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:7,代码来源:SpaceControlDelegate.cs


示例19: DrawGlyphWithColors

        public int DrawGlyphWithColors(IntPtr hdc, RECT[] pRect, int iMarkerType,
            IVsTextMarkerColorSet pMarkerColors, uint dwGlyphDrawFlags, int iLineHeight)
        {
            RECT rect = pRect[0];
            int rectWidth = rect.right - rect.left;
            int lineWidth = 8;// 2 + rectWidth / 20;

            uint clrFore;
            uint clrBack;
            ErrorHandler.ThrowOnFailure(pMarkerColors.GetMarkerColors(JiraLinkMarginMarkerType.Id, out clrFore, out clrBack));

            int drawColorref = (int)clrFore;
            Color color = Color.FromArgb(
                drawColorref & 0x0000FF,
                (drawColorref & 0x00FF00) >> 8,
                (drawColorref & 0xFF0000) >> 16
                );

            using (Graphics graphics = Graphics.FromHdc(hdc))
            using (SolidBrush brush = new SolidBrush(color))
            {
                graphics.FillRectangle(brush, rect.left + (rectWidth - lineWidth) / 2, rect.top, lineWidth, rect.bottom - rect.top);
            }

            return VSConstants.S_OK;
        }
开发者ID:spncrgr,项目名称:connector-idea,代码行数:26,代码来源:JiraLinkBackgroundMarkerType.cs


示例20: GetWindowRect

        public static Rectangle GetWindowRect(IntPtr hWnd)
        {
            RECT rect = new RECT();
            GetWindowRect(hWnd, ref rect);

            return new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
        }
开发者ID:anirnet,项目名称:raf-manager,代码行数:7,代码来源:WinAPI.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RESTCommand类代码示例发布时间:2022-05-24
下一篇:
C# RC类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap