Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Animated Cursors

Hi,

Has anyone had success loading Animated Cursors from a resource file?

If so, could you give me a clue?

I have no trouble loading them from a file(LoadCursorFromFile(....).

Thanks,'

Dick


Comments

  • : Hi,

    : Has anyone had success loading Animated Cursors from a resource file?

    : If so, could you give me a clue?

    : I have no trouble loading them from a file(LoadCursorFromFile(....).

    : Thanks,'

    : Dick

    :



    I'm working in C/C++.


  • Just add it by hand, open the RC file as text, add this line

    IDC_CURSOR1 CURSOR DISCARDABLE "filename.ani"



    now you can use it as normal, for example

    WNDCLASS.hCursor = LoadCursor( hInstance, MAKEINTRESOURCE( IDC_CURSOR1 ) );



    : : Hi,

    : : Has anyone had success loading Animated Cursors from a resource file?

    : : If so, could you give me a clue?

    : : I have no trouble loading them from a file(LoadCursorFromFile(....).

    : : Thanks,'

    : : Dick

    : :

    :

    : I'm working in C/C++.

    :






  • Greetings

    I've tried this method in my .rc files however I get an invalid cursor format error from the compiler (Borland's C++ 4.52). It works fine with standard .cur's if there only 2 color (black & white), If I try useing anything over 2 colors I get the same error (invalid cursor format). I'm including windows.h in the .rc for DS_3DLOOK, is there another header file I need for the cursor??



    Thank You

    Stoic Joker



    : Just add it by hand, open the RC file as text, add this line

    : IDC_CURSOR1 CURSOR DISCARDABLE "filename.ani"

    :

    : now you can use it as normal, for example

    : WNDCLASS.hCursor = LoadCursor( hInstance, MAKEINTRESOURCE( IDC_CURSOR1 ) );

    :

    : : : Hi,

    : : : Has anyone had success loading Animated Cursors from a resource file?

    : : : If so, could you give me a clue?

    : : : I have no trouble loading them from a file(LoadCursorFromFile(....).

    : : : Thanks,'

    : : : Dick

    : : :

    : :

    : : I'm working in C/C++.

    : :

    :

    :

    :






  • : Hi,

    : Has anyone had success loading Animated Cursors from a resource file?

    : If so, could you give me a clue?

    : I have no trouble loading them from a file(LoadCursorFromFile(....).

    : Thanks,'

    : Dick

    :



    Here is what i ended up with. Some of the code came from 'CodeGuru'.



    hrs = FindResource(g_hInst,MAKEINTRESOURCE(EPC),"ANICURSORS");

    resize = SizeofResource(g_hInst,hrs);

    hGlob = LoadResource(g_hInst,hrs);

    pBytes=(LPBYTE)LockResource(hGlob);

    hfile = CreateFile("temp.ani",GENERIC_READ|GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);

    if(hfile == INVALID_HANDLE_VALUE)

    MessageBox(NULL,"no file","",MB_OK);

    if(!WriteFile(hfile,pBytes,resize,&bwrtn,NULL))

    MessageBox(NULL,"no bytes","",MB_OK);

    CloseHandle(hfile);

    hcur = LoadCursorFromFile("temp.ani");



    To save space I didn't include the Var's declarations.

    g_hInst is a globle HINSTANCE made = to hInstance in WinMain().


  • I've been having the same problem. The hex code for the cursor is IN the resource file (I can open it in notepad and view it). I read somewhere that windows 9x has a problem with anicursors with a color depth > 4 bit (16 colors). I downloaded an editor program and checked the cursor that I was using and it's 16color... It loads fine from resource file under NT4 and win2000, but will not load under 95/98 unless written to a temp file and read in from there.



    If ANYONE finds the solution to this, I'd love to know what it takes. Here is what I - with help from Code-guru and someone else I've talked to have come up with. As with an earlier post, ugly, but functional -

    (sorry the formatting goes to hell in this window)



    HCURSOR CFTPFMDlg::SetConnectCursor()

    {

    HRSRC hRes=FindResource(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_ANI_GLOBE2),"ANICURSORS");

    DWORD dwSize=SizeofResource(AfxGetInstanceHandle(),hRes);

    HGLOBAL hGlob=LoadResource(AfxGetInstanceHandle(),hRes);

    LPBYTE pBytes=(LPBYTE)LockResource(hGlob);

    HCURSOR cAni=(HCURSOR)CreateIconFromResource(pBytes,dwSize,FALSE,0x00030000);



    //this SUCKS, but it's a work-around for windows 95/98

    if (cAni == NULL)

    {

    char szStr[256];

    CFile cFile;

    CFileException cFile_Error;



    GetWindowsDirectory(szStr, sizeof(szStr));

    strcat(szStr, _T("\TEMP.ANI"));

    cFile.Open(szStr, CFile::modeCreate | CFile::modeWrite, &cFile_Error);

    cFile.Write(pBytes, dwSize);

    cFile.Close();

    cAni = LoadCursorFromFile(szStr);

    DeleteFile(szStr);

    }

    return cAni;

    }





    : Greetings

    : I've tried this method in my .rc files however I get an invalid cursor format error from the compiler (Borland's C++ 4.52). It works fine with standard .cur's if there only 2 color (black & white), If I try useing anything over 2 colors I get the same error (invalid cursor format). I'm including windows.h in the .rc for DS_3DLOOK, is there another header file I need for the cursor??




Sign In or Register to comment.