change mouse cursor c#

  • Thread starter Thread starter family.glick
  • Start date Start date
F

family.glick

hi there!
i would like to change the mouse cursor once the user is pressing on a
button.
i would like it to change to a jpg file i have. (if it's a problem
maybe a bmp file will help).
how do i deal with it?
 
i would like to change the mouse cursor once the user is pressing on a
button.
i would like it to change to a jpg file i have. (if it's a problem
maybe a bmp file will help).

You may want to use a cursor file ("*.cur", can be created using VS) and the
'Cursor' class to load the file at runtime. Assign the cursor to
'Cursor.Current' or the form's or control's 'Cursor' property.
 
Hi all
I found out some time ago the same probelm and the solution to that is
to use the following lines of code
//========================Code================================
// create any bitmap
Bitmap b = new Bitmap( 55, 25 );
Graphics g = Graphics.FromImage ( b );
// do whatever you wish
g.DrawString ( "arya", this.Font, Brushes.Blue, 0, 0 );
// this is the trick!
IntPtr ptr = b.GetHicon();
Cursor c = new Cursor(ptr );
// attach cursor to the form
this.Cursor = c;
//========================Code================================
I found this code some time back it is really interesting
I found this code at http://www.ii.uni.wroc.pl/~wzychla/cs_enFAQ.html


Regards
aryasheel
 
I think it is better to convert the bitmap to the cursor using some
tool prior to compilation rather than converting at runtime.
 
Truong Hong Thi said:
I think it is better to convert the bitmap to the cursor using some
tool prior to compilation rather than converting at runtime.

ACK, because this would allow specifying the hotspot.
 
Back
Top