private void button1_Click(object sender, EventArgs e)
        {
            mh = new MouseHook();
            mh.SetHook();
            mh.MouseDownEvent += mh_MouseDownEvent;
            mh.MouseUpEvent   += mh_MouseUpEvent;
            mh.MouseMoveEvent += mh_MouseMoveEvent;
            //CaptureApi.mouse_event(CaptureApi.MouseEventFlag.LeftDown,0,0,)

            //System.IntPtr DesktopHandle = Win32Api.GetDC(System.IntPtr.Zero);
            //Graphics g = Graphics.FromHdc(DesktopHandle);
            //g.DrawRectangle(new Pen(Color.Red), new Rectangle(300, 300, 100, 100));
            //g.Dispose();
        }
Example #2
0
        public FrmCapture()
        {
            InitializeComponent();

            SetStyle(ControlStyles.OptimizedDoubleBuffer
                     | ControlStyles.ResizeRedraw
                     | ControlStyles.Selectable
                     | ControlStyles.AllPaintingInWmPaint
                     | ControlStyles.UserPaint
                     | ControlStyles.SupportsTransparentBackColor,
                     true);

            // 如果1号屏幕在右边,那就不行了
            FormBorderStyle = FormBorderStyle.None;
            Location        = StartLocation;

            Size          = new Size(ScreenWidth, ScreenHeight);
            TopMost       = true;
            ShowInTaskbar = false;

            m_MHook           = new MouseHook();
            this.FormClosing += (s, e) =>
            {
                try
                {
                    this.timer1.Dispose();
                    m_MHook.UnLoadHook();
                    this.DeleteResource();
                }
                catch (Exception exception)
                {
                    System.Diagnostics.Debug.WriteLine($"FormClosing {exception}");
                }
            };
            this.panel1.Paint           += panel1_Paint;
            this.panel2.Paint           += panel1_Paint;
            imageProcessBox1.MouseLeave += (s, e) => this.Cursor = Cursors.Default;
            //后期一些操作历史记录图层
            m_layer = new List <Bitmap>();
        }