Reputation: 18909
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
Reputation: 5248
for deep information visit MSDN Link: http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.size.aspx
Upvotes: 0
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
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