Saturday, June 7, 2008

Changing the shape of Mouse Pointer

I was searching for a way to change the shape of mouse pointer in C#. Say, in any application a button is clicked and the application is performing some functions on the back end, there must be some way through which the user can know that something is working, otherwise the confused user would go on pressing buttons and irritated the user would close the application.
(I know, I know I am not telling you anything new :P)
Anyways, I was searching for a way to do this. I wanted to change the mouse pointer to look like an hourglass to signify "be patient, work is being done, your output will be served to you soon". A simple hourglass to say all that.
First MSDN search returned a page that taught how to change the shape in VB.Net then while checking other articles I found a namespace by the name "System.Windows.Input". But I think it's not a namespace of C# 2005.
Amazingly I found my answer in a question. To change the shape all you have to do is write the following line of code:

Cursor.Current = Cursors.WaitCursor;

As soon as the function ends the cursor turns back to it's original shape.

In case you want to change it back to original shape before the function ends, here's what you'll have to write
Cursor.Current = Cursors.Arrow;

This is where I read it from.

2 comments:

Mohammad Mustafa Ahmedza said...

Salam,

I am extremely delighted to see a Pakistani on blogger. Well nice blog, I was searching for how to change my pointers shape on blogger and fortunately I met your blog. Good to see a Pakistani involved on a world wide activity.
Please don't forget to visit my websites,
www.Qiyamah.co.nr
www.TECfun.co.nr [ My Blog ]

I will be honoured if you leave your enlighting comments on my sites.
God bless you.

Regards,
Mustafa,
Karachi, Pakistan.

Originally Posted on:
August 25, 2008 10:04 AM

Nazia Gilani said...

This was very enlightening...technical things aur dala kar...they really interest me:)

Originally Posted on:
September 26, 2008 1:57 AM