views:

12

answers:

0

I have used the following code to load an animated cursor on my applicaiton.

    class Animated
    {
       [DllImport("User32.dll")]
       private static extern IntPtr LoadCursorFromFile(String str);

       public static Cursor WaitCursor()
       {
           IntPtr hCursor = LoadCursorFromFile("C:\\WINDOWS\\Cursors\\appstar3.ani");

           if (!IntPtr.Zero.Equals(hCursor))
           {
               return new Cursor(hCursor);
           }
           else
           {
               return Cursors.WaitCursor;
           }
       }
    }

And call it from another form as such.

    private void cmdOk_Click(object sender, EventArgs e)
    {
       this.Cursor = Animated.WaitCursor();
       LoadReport();
       this.Cursor = Cursors.Default;
    }

It animates at first but goes back to unanimated version after a few seconds. Is there any reason this is happening? Is there any other way I can do this in a better way?