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#动态对象dynamic实现方法和属性动态代码详解

C#如何利用reportviewer来生成报表的示例代码分享(图)

C#学习记录:编写高质量代码改善整理建议1-3

详解C# 控制台倒计时

C#字符串处理小工具的详细介绍

.net和C#有什么区别

C#相关面试题

简述C#中builder和buffer类的用法详解

具体详解C#中三个关键字(params,ref,out)

C#如何使用?C#的基本语法

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




打赏

取消

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

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

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

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

评论

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