我需要获取经典 windows 光标矩形的大小。
如何在 C# 中获取光标的大小?
您可以使用Cursor.Size:
int cursorWidth = Cursor.Size.Width;
int cursorHeight = Cursor.Size.Height;
是的,就是这么简单!
希望这可以帮助!
一个小例子:参考
if(this.Cursor != Cursors.Hand &
Cursor.Current == Cursors.Default)
{
// Draw the cursor stretched.
Graphics graphics = this.CreateGraphics();
Rectangle rectangle = new Rectangle(
new Point(10,10), new Size(cursor.Size.Width * 2,
cursor.Size.Height * 2));
cursor.DrawStretched(graphics, rectangle);
// Draw the cursor in normal size.
rectangle.Location = new Point(
rectangle.Width + rectangle.Location.X,
rectangle.Height + rectangle.Location.Y);
rectangle.Size = cursor.Size;
cursor.Draw(graphics, rectangle);
// Dispose of the cursor.
cursor.Dispose();
}
有关详细信息,请访问 MSDN 链接:http: //msdn.microsoft.com/en-us/library/system.windows.forms.cursor.size.aspx