首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

用 C# 實現截圖功能(二):建立截圖主視窗 ScreenBody

     編輯:關於C語言

2. 建立截圖主視窗

核心類別 MyRectangle 完成後,接著建立主視窗。使用 VS2005 新建專案 ScreenCutter,主視窗命名 MainForm,新增視窗 ScreenBody 並設定:

  • ShowInTaskbar = False
  • TopMost = True
  • FormBorderStyle = None

於 ScreenBody 加入 Panel (panel1),背景色設藍色,內含 Label 顯示座標與尺寸(labelLocation、labelWidth、labelHeight)。

命名空間與私有成員

using System;
using System.Drawing;
using System.Windows.Forms;

namespace ScreenCutter
{
    public partial class ScreenBody : Form
    {
        private Graphics MainPainter;
        private bool isDowned;
        private bool RectReady;
        private Image baseImage;
        private Point moveModeDownPoint;
        private MyRectangle myRectangle;
        private bool moveMode;
        private bool changeSizeMode;

        public ScreenBody()
        {
            InitializeComponent();
            panel1.Location = new Point(this.Left, this.Top);
            myRectangle = new MyRectangle();
            moveModeDownPoint = new Point();
            this.Cursor = myRectangle.MyCursor;
        }
        // 後續事件處理見下一篇……
    }
}
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved