• 大小: 0.04M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-04-23
  • 语言: C#
  • 标签: 获取  

资源简介


获取当前鼠标形状:

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        [StructLayout(LayoutKind.Sequential)]
        struct CURSORINFO
        {
            public int cbSize;
            public int flags;
            public IntPtr hCursor;
            public Point ptScreenPos;
        }
        [DllImport(“user32.dll“)]
        static extern bool GetCursorInfo(out CURSORINFO pci);
        private const int CURSOR_SHOWING = 0x00000001;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_KeyPress(object sender KeyPressEventArgs e)
        {
            CURSORINFO vCurosrInfo;
            vCurosrInfo.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
            GetCursorInfo(out vCurosrInfo);
            if ((vCurosrInfo.flags & CURSOR_SHOWING) != CURSOR_SHOWING) return;
            Cursor vCursor = new Cursor(vCurosrInfo.hCursor);
            Graphics vGraphics = Graphics.FromHwnd(Handle);
            Rectangle vRectangle = new Rectangle(95 50 32 32);
            vGraphics.FillRectangle(new SolidBrush(BackColor) vRectangle);
            vCursor.Draw(vGraphics vRectangle);
        }



        private void Form1_MouseClick(object sender MouseEventArgs e)
        {
            CURSORINFO vCurosrInfo;
            vCurosrInfo.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
            GetCursorInfo(out vCurosrInfo);
            if ((vCurosrInfo.flags & CURSOR_SHOWING) != CURSOR_SHOWING) return;
            Cursor vCursor = new Cursor(vCurosrInfo.hCursor);
            Graphics vGraphics = Graphics.FromHwnd(Handle);

            Rectangle vRectangle = new Rectangle(e.X e.Y 32 32);
            vGraphics.FillRectangle(new SolidBrush(BackColor) vRectangle);
            vCursor.Draw(vGraphics vRectangle);
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       9216  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件      22016  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      11600  2021-01-25 16:59  WinAPI获取光标形状\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        490  2019-12-07 17:10  WinAPI获取光标形状\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       2106  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\Form1.cs

     文件       1652  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\Form1.Designer.cs

     文件       5817  2021-01-25 16:57  WinAPI获取光标形状\WindowsFormsApplication1\Form1.resx

     文件       2867  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6468  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1808  2021-01-25 16:59  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件        975  2021-01-25 16:57  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件       9216  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.exe

     文件        180  2021-01-25 16:57  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Form1.resources

     文件      22016  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.pdb

     文件        180  2020-12-28 09:41  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        505  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\Program.cs

     文件       1398  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\Properties\AssemblyInfo.cs

     文件       2900  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\Properties\Resources.Designer.cs

     文件       5612  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\Properties\Resources.resx

     文件       1111  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\Properties\Settings.Designer.cs

     文件        249  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\Properties\Settings.settings

     文件       3707  2020-12-28 09:41  WinAPI获取光标形状\WindowsFormsApplication1\WindowsFormsApplication1.csproj

     文件        914  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1.sln

    ..A..H.     20992  2021-01-25 16:59  WinAPI获取光标形状\WindowsFormsApplication1.suo

     目录          0  2020-12-28 09:39  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug\TempPE

     目录          0  2021-01-25 16:58  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86\Debug

     目录          0  2021-01-11 20:27  WinAPI获取光标形状\WindowsFormsApplication1\bin\Debug

     目录          0  2021-01-11 20:27  WinAPI获取光标形状\WindowsFormsApplication1\obj\x86

     目录          0  2021-01-11 20:27  WinAPI获取光标形状\WindowsFormsApplication1\bin

     目录          0  2021-01-11 20:27  WinAPI获取光标形状\WindowsFormsApplication1\obj

............此处省略6个文件信息

评论

共有 条评论