After I could not locate a method for displaying animated cursors from a resource,
I found a way myself.
Essentially (with error checking removed), here’s the code path.
HCURSOR LoadAnimatedCursor(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 import an .ANI file to the resource script:
- Insert->Resource->Import: Load the .ANI file
- Select the new resource into a user defined type named: ANICURSORS
Downloads
Download demo project – 40 Kb