CSharp/C# >> wpf animated cursor

by Andy O'Neill » Fri, 22 Jan 2010 20:45:07 GMT

I'm trying to use an animated cursor in a WPF application.
Something is going wrong and I can't work it out.
I wonder if anyone has come across this previously.

I copy stopwtch.ani to the project folder.
Add it to the project.
Set it's build property to resource

Use the following code snippet:
StreamResourceInfo sri = Application.GetResourceStream
(new Uri("stopwtch.ani", UriKind.Relative));
Cursor customCursor = new Cursor(sri.Stream);
this.Cursor = customCursor;

Cannot locate resource 'stopwtch.ani'.

Thanks in anticipation.

Similar Threads

1. Displaying animated cursors.

Hi all,
I want to display an animated cursor associated to the cursor property of a
but the animated cursors (.ani files) are not supported by the Cursor class.
Is there any other way to do it.

2. Animated cursor as a resource

3. Displaying Animated Cursor


I am trying to display an animated cursor.
I found several examples, but none of the
examples seem to work in my SDI app.
When I use the anmiated cursor, the cursor
completely vanishes.

How can I display an animated cursor in an
SDI app?  VS2008 MFC

BOOL CMyFormView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 

//    ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)) ;  //this works
      ::SetCursor(LoadAnimatedCursor(IDR_HOURGLASS)); //this fails
      return true;

HCURSOR CMyFormView::LoadAnimatedCursor(UINT nResID)
	DWORD dwSize=SizeofResource(AfxGetInstanceHandle(),hRes);
	HGLOBAL hGlob=LoadResource(AfxGetInstanceHandle(),hRes);
	LPBYTE pBytes=(LPBYTE)LockResource(hGlob);	
	return hCur;


4. Animated Cursors for Pocket PC 2002? - Windows CE

5. Using Animated Cursors

Anyone knowes how to use Animated Cursors ( *.ani files) in Winform
Applications ?

According to MSDN , The Cursor class in the framework does not support
animated Cursors, only regular ones ( *.cur files).

Any known workarounds ?



6. animated cursors - VB.Net

7. Loading animated cursor resource

I'm trying to load an animated cursor resource directly from the exe file.
I have added it in into the assembly and set it's build action to embedded

I have a function written as follows:

Private Function GetResCursor(ByVal strIdentifier As String) As Cursor
     Return New
End Function

When I call the function with the following:
     m_BusyCursor = GetResCursor("FileSearch.cross.cur")
everything works just fine and I'm able to change the cursor.

However, when I call GetResCursor with this:
     m_BusyCursor = GetResCursor("FileSearch.busy.ani")
and specify an animated cursor, I receive the following exception:

        An unhandled exception of type 'System.ArgumentException' occurred
in system.windows.forms.dll
        Additional information: Invalid image format. The image file may be

I know the image isn't corrupt as I'm able to use this animated cursor file
under mouse properties.

Any suggestions???



8. Animated GIFs don't animate