locked
Changing mouse cursor runtime PERMANENT RRS feed

  • Question

  • Hey

    Im using Visual Studio 2008 and framework 2.0 and i have trouble how to change mouse cursor. The thing is that i need to change it in runtime.

    I tried to seach the net but nothing worked for me.

    I tried this :

    this.Cursor = Cursors.Help;

    but it seems that the cursor is only changed in the form wich is opened. But i want the cursor changed so when u navigate out of the form in the desktop or else the same changed cursor need to be maintained.

    The following code was used to change the cursor from the icon:

    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;


    but still it is just in the form that the cursor is maintained.

    My mission is to create systray icon wich will contain GUI for changing the cursor from an icon or pic. this will change the cursor and then minimize the sys tray icon. the cursor will be kept as long as the program runs when the program shuts down the cursor will change to the default windows cursor.

    Thank you hope you can help.

    Wednesday, January 21, 2009 3:02 PM

Answers