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#线程与线程池的区别

.net是否真的被国内市场嫌弃?

C# 2.0 specification (四)

C#中如何操作word的方法示例

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

C#开发实例-订制屏幕截图工具(七)添加放大镜功能的代码示例

讲解什么是msmq

.net框架-微软给出的C#编程风格代码实例

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




打赏

取消

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

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

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

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

评论

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