ibrahimyilmaz
ibrahimyilmaz

Reputation: 18909

How to get size of cursor in C#

I need to get the size of rectangle of classical windows cursor.

How can I get the size of the cursor in c#?

Upvotes: 5

Views: 4207

Answers (3)

Mahmut EFE
Mahmut EFE

Reputation: 5248

for deep information visit MSDN Link: http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.size.aspx

Upvotes: 0

Ebad Masood
Ebad Masood

Reputation: 2379

A small example : Reference

       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();
   }

Upvotes: 2

matthewr
matthewr

Reputation: 4739

You can use Cursor.Size:

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

Yes, it is really that simple!

Hope this helps!

Upvotes: 10

Related Questions