Click here to Skip to main content
11,933,180 members (57,512 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked

Display Animated Cursors stored in Resources

, 14 Dec 1999
Rate this:
Please Sign up or sign in to vote.
Demonstrates how to use an animated gif stored in your resource file as an animated cursor
  • Download demo project - 21 Kb
  • Download source files - 1 Kb
  • <!-- Article Starts -->

    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.


    You then use the following function which loads the gif and displays it as an animated cursor:

    // LoadAnimatedCursor: Loads an animated gif from the resource as an cursor
    HCURSOR LoadAniCursor(UINT nID)
    	HINSTANCE hInst=AfxGetInstanceHandle();
    	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))


    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


    About the Author

    Bernd Wißler
    Germany Germany
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    QuestionHere is how to Prevent the Cursor Disappearing Pin
    davesmills21-May-15 1:35
    memberdavesmills21-May-15 1:35 
    QuestionCannot work in Multiple Documents dialog Pin
    kevanphua27-May-07 17:40
    memberkevanphua27-May-07 17:40 
    QuestionLoading 256-color animated cursors? Pin
    Bartosz Bien7-Jun-06 11:33
    memberBartosz Bien7-Jun-06 11:33 
    QuestionWhere to put LoadAniCursor()? Pin
    lasombra197928-Nov-04 23:31
    memberlasombra197928-Nov-04 23:31 
    QuestionMSFlexgrid distribute? Pin
    José Luis Sogorb28-Nov-04 8:22
    memberJosé Luis Sogorb28-Nov-04 8:22 
    GeneralUne autre facon, qui marche sur toutes plateformes: Pin
    Joshu22-Mar-03 18:36
    sussJoshu22-Mar-03 18:36 
    GeneralResource leak! Pin
    Robert Space19-Mar-02 22:01
    memberRobert Space19-Mar-02 22:01 
    GeneralA different way... Pin
    Sibilant1-Mar-02 16:44
    memberSibilant1-Mar-02 16:44 
    Sibilant1-Mar-02 8:55
    memberSibilant1-Mar-02 8:55 
    GeneralHave a solution for Win9X Here Pin
    figmo24-Oct-01 14:35
    memberfigmo24-Oct-01 14:35 
    GeneralRe: Have a solution for Win9X Here Pin
    Anonymous24-Oct-01 15:15
    memberAnonymous24-Oct-01 15:15 
    GeneralRe: Have a solution for Win9X Here Pin
    Nonni5-Nov-01 23:45
    memberNonni5-Nov-01 23:45 
    GeneralUsing the example code Pin
    Ron Maman27-Nov-00 0:53
    memberRon Maman27-Nov-00 0:53 
    GeneralCreateIconFromResource() Always failed !!! Pin
    Homles Chen22-Sep-00 0:10
    sussHomles Chen22-Sep-00 0:10 
    GeneralWorking great but.... Pin
    Kishk9110-Mar-00 10:21
    sussKishk9110-Mar-00 10:21 
    GeneralWorking great but.... Pin
    Kishk9110-Mar-00 10:21
    sussKishk9110-Mar-00 10:21 
    The code is working great..
    but is there any known problem when you imported more then one ani cursor??
    GeneralNot a GIF, but a simple ANI cursor! Pin
    PPEscher22-Jan-00 14:14
    sussPPEscher22-Jan-00 14:14 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web04 | 2.8.151126.1 | Last Updated 15 Dec 1999
    Article Copyright 1999 by Bernd Wißler
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid