CaptureItPlus/Capturemodes/frmWindowCapture.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using dotnetthoughts.CaptureItPlus;

namespace CaptureItPlus.Capturemodes
{
    public partial class frmWindowCapture : Form
    {
        private bool _isCaptured;
        private IntPtr _lastWindow;
        public frmWindowCapture()
        {
            InitializeComponent();
        }
        public string FileName { private set; get; }

        private void picFinder_Click(object sender, EventArgs e)
        {
            CaptureMouse(true);
        }

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case (int)NativeMethods.WM_LBUTTONUP:
                    CaptureWindow();
                    CaptureMouse(false);
                    CloseWindow();
                    break;
                case (int)NativeMethods.WM_MOUSEMOVE:
                    HandleMouseMoves();
                    break;
            }
            base.WndProc(ref m);
        }

        private void CloseWindow()
        {
            if (_isCaptured)
            {
                NativeMethods.ReleaseCapture();
            }
            DialogResult = DialogResult.OK;
            Close();
        }

        private void CaptureWindow()
        {
            var handle = NativeMethods.WindowFromPoint(Cursor.Position);
            if (handle != IntPtr.Zero)
            {
                _lastWindow = handle;
                NativeMethods.SetForegroundWindow(handle);
                Opacity = 0;
                var rect = new NativeMethods.RECT();
                NativeMethods.GetWindowRect(handle, ref rect);

后面还有 89 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。