- 爱易网页
-
ASP.NET教程
- C#中获得系统当前鼠标的图案
日期:2011-07-23 浏览次数:20516 次
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);
}
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。