C#获取系统当前鼠标的图案示例代码


本文摘自PHP中文网,作者黄舟,侵删。

C#获取系统当前鼠标的图案代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

using System.Runtime.InteropServices;

  

[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;

  

private void button1_Click(object sender, EventArgs 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(0, 0, 32, 32);

    vGraphics.FillRectangle(new SolidBrush(BackColor), vRectangle);

    vCursor.Draw(vGraphics, vRectangle);

}

以上就是C#获取系统当前鼠标的图案示例代码的详细内容!

相关阅读 >>

C#获取本机ip搜集整理7种方法的示例代码分享

新手学习.net编程计划-1

详解C#获取本机ip地址(ipv4)的代码案例

简单介绍C#中数组、arraylist、list、dictionary的用法与区别

C#开发实例-订制屏幕截图工具(二)创建项目、注册热键、显示截图主窗口

C#使用反射来实现对象的深度复制的示例代码分享

详细介绍C# 中 asp.net web api 的 roc

C#如何计算2个字符串相似度的示例代码分享

C#获取listview鼠标下的item案例

C#注册控件处理程序(setconsolectrlhandler)函数示例的详细介绍

更多相关阅读请进入《C#》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...