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#如何删除ul及li中指定标签里文字的方法详解

C# windowsapi应用之getdesktopwindow-获得桌面所有窗口句柄的方法详解

C#日期格式转换的公共方法类的实现详解

C# 带滚动条的label控件的示例代码详解

怎样用C#打印一个n行的菱形?实战详解

C#开发之微信小程序发送模板消息功能

简单介绍C#中的委托,事件与异步的用法

详细介绍C#批量生成随机密码必须包含数字和字母并用加密算法加密的代码案例

C#设计模式-派生类实现非虚接口陷阱的实例代码分享

详细介绍用C#描述数据结构3:arraylist的图文代码

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




打赏

取消

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

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

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

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

评论

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