5

我需要获取经典 windows 光标矩形的大小。

如何在 C# 中获取光标的大小?

4

3 回答 3

9

您可以使用Cursor.Size

int cursorWidth = Cursor.Size.Width;
int cursorHeight = Cursor.Size.Height;

是的,就是这么简单!

希望这可以帮助!

于 2012-06-18T11:14:58.577 回答
2

一个小例子:参考

       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();
   }
于 2012-06-18T11:20:23.970 回答
0

有关详细信息,请访问 MSDN 链接:http: //msdn.microsoft.com/en-us/library/system.windows.forms.cursor.size.aspx

于 2012-06-18T11:53:08.887 回答