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


C# Forms.RECT类代码示例

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


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

示例1: OnTick_Timer

        public void OnTick_Timer(object sender, EventArgs e)
        {
            ++tick;
            var rem = 5 - (tick / 60);
            if (rem == 0)
            {
                timer.Stop();

                var hWnd = GetForegroundWindow();
                var winRect = new RECT();
                GetWindowRect(hWnd, ref winRect);
                if (X == null && Y == null)
                {
                    X = Screen.PrimaryScreen.Bounds.Width - Screen.PrimaryScreen.WorkingArea.Width + 20;
                    Y = Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height + 20;
                }
                if (H == null && W == null)
                {
                    W = winRect.right - winRect.left;
                    H = winRect.bottom - winRect.top;
                }
                MoveWindow(hWnd, X.Value, Y.Value, W.Value, H.Value, 0);

                lab_cntdown.Text = "―";
                tick = 0;
                X = Y = H = W = null;
            }
            else if (rem > 0) {
                lab_cntdown.Text = rem.ToString();
            }
        }
开发者ID:oykdn2109,项目名称:Mover,代码行数:31,代码来源:Form1.cs

示例2: DrawThemeTextActive

 public static void DrawThemeTextActive(
     Graphics aGraph,
     string aText,
     Point aLocation,
     SUxTextProperties aProp
     )
 {
     IntPtr lPriHdc = aGraph.GetHdc();
     VisualStyleRenderer lRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
     DTTOPTS lOpts = new DTTOPTS();
     lOpts.dwSize = Marshal.SizeOf(lOpts);
     lOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
     lOpts.crText = ColorTranslator.ToWin32(aProp.color);
     lOpts.iGlowSize = aProp.glowSize;
     RECT ltBounds = new RECT(0, 0, aProp.bounds.Width, aProp.bounds.Height);
     DrawThemeTextEx(
                 lRenderer.Handle,
                 lPriHdc,
                 0, 0,
                 aText,
                 -1,
                 (int)(aProp.flags),
                 ref ltBounds,
                 ref lOpts
             );
 }
开发者ID:ahalassy,项目名称:reportsmart,代码行数:26,代码来源:UXTheme_DLL.cs

示例3: CaptureActiveWindow

		/// <summary>アクティブなウィンドウの画像を取得する</summary>
		/// <returns>アクティブなウィンドウの画像</returns>
		public static Bitmap CaptureActiveWindow()
		{
			//アクティブなウィンドウのデバイスコンテキストを取得
			IntPtr hWnd = GetForegroundWindow();
			IntPtr winDC = GetWindowDC(hWnd);

			//ウィンドウの大きさを取得
			RECT winRect = new RECT();
			GetWindowRect(hWnd, ref winRect);

			Bitmap bmp = new Bitmap(winRect.right - winRect.left, winRect.bottom - winRect.top);

			Graphics g = Graphics.FromImage(bmp);
			IntPtr hDC = g.GetHdc();

			//Bitmapに画像をコピーする
			BitBlt(hDC, 0, 0, bmp.Width, bmp.Height, winDC, 0, 0, SRCCOPY);

			//解放
			g.ReleaseHdc(hDC);
			g.Dispose();
			ReleaseDC(hWnd, winDC);

			return bmp;
		}
开发者ID:kokeiro001,项目名称:AutoMinesweeperSolver,代码行数:27,代码来源:CaptureHelper.cs

示例4: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            WinApi.SetWindowPos(this.Handle, WinApi.HWND_TOPMOST, 0, 0, 0, 0, WinApi.TOPMOST_FLAGS);
            _refreshThread = new Thread(RefreshThread);

            _sessionMgr = new SessionMgr();

            Layers = new Dictionary<string, ContainerControl>();

            AddHistogram("EXP_HISTOGRAM", "exp", 250, 30, 900, 40, Histogram.HistogramType.Average);
            AddHistogram("EXP_HISTOGRAM2", "exp2", 250, 30, 900, 80, Histogram.HistogramType.Value);
            AddHistogram("JEXP_HISTOGRAM", "jexp", 250, 30, 900, 120, Histogram.HistogramType.Average);

            Layers.Add("CLOCK", new Clock());
            var c = Layers["CLOCK"];
            c.Width = 250;
            c.Height = 250;
            c.Left = 900;
            c.Top = 90;
            this.Controls.Add(Layers["CLOCK"]);

            var rect = new RECT();
            var Ragexes = Process.GetProcessesByName("RagexeRE");
            if (Ragexes.Count() > 0)
            {
                var get = WinApi.GetWindowRect(Ragexes[0].MainWindowHandle, out rect);
                this.Location = new Point(rect.left, rect.top);
                this.Size = new Size(rect.right - rect.left, rect.bottom - rect.top);
            }
            _refreshThread.Start();
        }
开发者ID:samik3k,项目名称:RagnarokHUD,代码行数:31,代码来源:fHUD.cs

示例5: takeScreenshot

        public static Bitmap takeScreenshot()
        {
            try {
                RECT Rect = new RECT();
                if (ReadMemoryManager.FlashClient) {
                    Screen screen = Screen.FromControl(MainForm.mainForm);

                    Rect.left = screen.Bounds.Left;
                    Rect.right = screen.Bounds.Right;
                    Rect.top = screen.Bounds.Top;
                    Rect.bottom = screen.Bounds.Bottom;
                } else {
                    Process tibia_process = ProcessManager.GetTibiaProcess();
                    if (tibia_process == null) return null; //no tibia to take screenshot of

                    if (!GetWindowRect(tibia_process.MainWindowHandle, ref Rect)) return null;
                }

                Bitmap bitmap = new Bitmap(Rect.right - Rect.left, Rect.bottom - Rect.top);
                using (Graphics gr = Graphics.FromImage(bitmap)) {
                    gr.CopyFromScreen(new Point(Rect.left, Rect.top), Point.Empty, bitmap.Size);
                }
                return bitmap;
            } catch(Exception ex) {
                MainForm.mainForm.DisplayWarning("Failed to take screenshot: " + ex.Message);
                return null;
            }
        }
开发者ID:Mytherin,项目名称:Tibialyzer,代码行数:28,代码来源:ScreenshotManager.cs

示例6: GetBoundsTest

		public void GetBoundsTest()
		{
			RECT rect = new RECT();
			User32.GetWindowRect(_hWnd, ref rect);

			Assert.AreEqual(rect, Window.GetBounds(_hWnd));
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:7,代码来源:WindowTests.GetBounds.cs

示例7: Show

        public void Show()
        {
            // When opening a dialog from a console we endup on the primary screen
            // Instead we want the slideshow to be opened on the screen where the console is located.
            IntPtr h2 = GetConsoleWindow();
            RECT rect = new RECT();
            GetWindowRect(h2, ref rect);

            HtmlViewer viewer = new HtmlViewer();

            viewer.ShowInTaskbar = false;
            viewer.Show();

            // The window location can only be changed after the dialog is shown...
            viewer.Location = new System.Drawing.Point(rect.left, rect.top);
            viewer.WindowState = FormWindowState.Maximized;

            Cursor.Hide();

            viewer.Activate();
            SetForegroundWindow(viewer.Handle);

            while (!viewer.IsDisposed)
            {
                Application.DoEvents();
                Thread.Sleep(20);
            }

        }
开发者ID:thsmi,项目名称:SeeYouScoreExporter,代码行数:29,代码来源:ConsoleDialogLoader.cs

示例8: GetWindowSize

 public static Size GetWindowSize(IntPtr hWnd)
 {
   IntPtr winDC = GetWindowDC(hWnd);
   RECT rect = new RECT();
   GetWindowRect(hWnd, ref rect);
   return new Size(rect.right - rect.left, rect.bottom - rect.top);
 }
开发者ID:kokeiro001,项目名称:AutoMinesweeperSolver,代码行数:7,代码来源:CaptureHelper.cs

示例9: MessageBoxReplacer

        public MessageBoxReplacer(IWindowMessageHook hook)
        {
            _hook = hook;

            _hook.WindowMessageReceived += (sender, args) =>
            {
                var senderForm = args.SrcForm;
                if (senderForm == null)
                {
                    return;
                }
                if (args.Message.Msg != WM_APP_CENTERMSG)
                {
                    return;
                }

                var hWnd = GetForegroundWindow();
                if (hWnd == senderForm.Handle)
                {
                    return;
                }

                var r = new RECT();
                GetWindowRect(hWnd, ref r);
                var w = r.right - r.left;
                var h = r.bottom - r.top;
                var x = senderForm.Left + (senderForm.Width - w)/2;
                var y = senderForm.Top + (senderForm.Height - h)/2;
                MoveWindow(hWnd, x, y, w, h, 0);
            };
        }
开发者ID:posaunehm,项目名称:VagrantWin,代码行数:31,代码来源:MessageBoxReplacer.cs

示例10: GetWindowRect

 public static Rectangle GetWindowRect(IntPtr hWnd)
 {
     RECT r = new RECT();
     if (!GetWindowRect(hWnd, out r))
         return new Rectangle();
     else
         return new Rectangle(r.Left, r.Top, r.Right - r.Left, r.Bottom - r.Top);
 }
开发者ID:krysanto,项目名称:chiitrans2,代码行数:8,代码来源:PInvokeFunc.cs

示例11: Main

        static void Main(string[] args)
        {
            switch (args.Length > 0 ? args[0].Substring(0, 2) : string.Empty)
            {
                case "/c":
                    Application.EnableVisualStyles();

                    var polarisOptions = new OptionsWindow();

                    if (polarisOptions.ShowDialog() == DialogResult.OK)
                    {
                        polarisOptions.SaveSettings();
                    }
                    break;
                case "/p":
                    try
                    {
                        IntPtr previewWindowHandle = new IntPtr(uint.Parse(args[1]));

                        while (!IsWindowVisible(previewWindowHandle))
                        {
                            Application.DoEvents();
                            Thread.Sleep(0);
                        }

                        var previewWindowRect = new RECT();

                        GetClientRect(previewWindowHandle, ref previewWindowRect);

                        int cx = previewWindowRect.right / 2;
                        int cy = previewWindowRect.bottom / 2;
                        int radius = (int)(Math.Min(cx, cy) * 0.8);

                        var previewWindowRectangle = new RectangleF(cx - radius, cy - radius, radius * 2f, radius * 2f);

                        Application.DoEvents();
                        using (var graphics = Graphics.FromHwnd(previewWindowHandle))
                        {
                            graphics.Clear(Properties.Settings.Default.BackColor);

                            Renderer.RenderClock(previewWindowRectangle, graphics, true);

                            graphics.Flush();
                        }
                    }
                    catch
                    {

                    }

                    break;
                default:
                case "/s":
                    ShowScreensaver();
                    break;
            }
        }
开发者ID:qubbit,项目名称:polaris,代码行数:57,代码来源:Program.cs

示例12: Activate

		public void Activate(IntPtr hWndParent, RECT[] pRect, int bModal)
		{
            if ((null == pRect) || (0 == pRect.Length))
            {
                throw new ArgumentNullException("pRect");
            }
			Control parentControl = Control.FromHandle(hWndParent);
			RECT pageRectangle = pRect[0];
			MyPageView.Initialize(parentControl, Rectangle.FromLTRB(pageRectangle.left, pageRectangle.top, pageRectangle.right, pageRectangle.bottom));
		}
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:10,代码来源:PropertyPage.cs

示例13: GetActiveWindowBounds

        public static Rectangle GetActiveWindowBounds()
        {
            var windowHandle = GetForegroundWindow();

            RECT windowRect = new RECT();
            GetWindowRect(windowHandle, ref windowRect);

            Rectangle bounds = new Rectangle(windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top);

            return bounds;
        }
开发者ID:josiahpeters,项目名称:QwikShot,代码行数:11,代码来源:ScreenHelper.cs

示例14: DrawText

        public static void DrawText(Graphics graphics, string text, Font font, Rectangle bounds, Color color, TextFormatFlags flags, TextStyle textStyle)
        {
            if (!VisualStyleRenderer.IsSupported) {
                TextRenderer.DrawText(graphics, text, font, bounds, color, flags);
                return;
            }

            IntPtr primaryHdc = graphics.GetHdc();

            // Create a memory DC so we can work offscreen
            IntPtr memoryHdc = CreateCompatibleDC(primaryHdc);

            // Create a device-independent bitmap and select it into our DC
            BITMAPINFO info = new BITMAPINFO();
            info.biSize = Marshal.SizeOf(info);
            info.biWidth = bounds.Width;
            info.biHeight = -bounds.Height;
            info.biPlanes = 1;
            info.biBitCount = 32;
            info.biCompression = 0; // BI_RGB
            IntPtr dib = CreateDIBSection(primaryHdc, info, 0, 0, IntPtr.Zero, 0);
            SelectObject(memoryHdc, dib);

            // Create and select font
            IntPtr fontHandle = font.ToHfont();
            SelectObject(memoryHdc, fontHandle);

            // Draw glowing text
            VisualStyleRenderer renderer = new VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.Window.Caption.Active);
            DTTOPTS dttOpts = new DTTOPTS();
            dttOpts.dwSize = Marshal.SizeOf(typeof(DTTOPTS));

            if (textStyle == TextStyle.Glowing) {
                dttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR;
            }
            else {
                dttOpts.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR;
            }
            dttOpts.crText = ColorTranslator.ToWin32(color);
            dttOpts.iGlowSize = 8; // This is about the size Microsoft Word 2007 uses
            RECT textBounds = new RECT(0, 0, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
            DrawThemeTextEx(renderer.Handle, memoryHdc, 0, 0, text, -1, (int)flags, ref textBounds, ref dttOpts);

            // Copy to foreground
            const int SRCCOPY = 0x00CC0020;
            BitBlt(primaryHdc, bounds.Left, bounds.Top, bounds.Width, bounds.Height, memoryHdc, 0, 0, SRCCOPY);

            // Clean up
            DeleteObject(fontHandle);
            DeleteObject(dib);
            DeleteDC(memoryHdc);

            graphics.ReleaseHdc(primaryHdc);
        }
开发者ID:kzys,项目名称:Gmail-Notifier-Plus,代码行数:54,代码来源:GlassHelper.cs

示例15: IsForegroundFullScreen

        public static bool IsForegroundFullScreen(Screen screen)
        {
            if (screen == null)
            {
                screen = Screen.PrimaryScreen;
            }
            var foregroundWindow = GetForegroundWindow();

            RECT rect = new RECT();
            GetWindowRect(new HandleRef(null, foregroundWindow), ref rect);
            return new System.Drawing.Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top).Contains(screen.Bounds);
        }
开发者ID:yjk282,项目名称:Weather,代码行数:12,代码来源:DetectFullScreenApplication.cs


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