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#单位转换器的图文代码详细介绍

带你了解C#中的构造函数

C#winform创建excel文件的示例代码分享

详解C#把datatable中数据一次插入数据库的示例代码

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

unity3d用什么语言开发?

C#操作iis创建应用程序池出现异常:无效索引的解决方法

C#中default什么意思

C# tabcontrol组件如何切换显示form窗体的示例代码

C#基础入门-常量详解

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




打赏

取消

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

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

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

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

评论

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