This article describes how you can display an animated cursor that is created from an animated gif and stored in your applications resources.
Before you can display it, you must import the animated gif into your resource file. You do this by declaring the animated gif file as a new user defined resource named "ANICURSOR
" within your resource file.
IDR_HORSE_CURSOR ANICURSORS DISCARDABLE "res\\horse.ani"
You then use the following function which loads the gif and displays it as an animated cursor:
HCURSOR LoadAniCursor(UINT nID)
{
HINSTANCE hInst=AfxGetInstanceHandle();
HRSRC hRes=FindResource(hInst,MAKEINTRESOURCE(nID),"ANICURSORS");
DWORD dwSize=SizeofResource(hInst, hRes);
HGLOBAL hGlob=LoadResource(hInst, hRes);
LPBYTE pBytes=(LPBYTE)LockResource(hGlob);
return (HCURSOR)CreateIconFromResource(pBytes,dwSize,FALSE,0x00030000);
}
To display the cursor, call SetCursor(LoadAniCursor(ID_ANIMATED_HORSE))
.
License
This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.
A list of licenses authors might use can be found here.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.