News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Animated cursor from resource ?

Started by dougiem, April 05, 2005, 12:31:22 AM

Previous topic - Next topic

dougiem

I am trying to load an animated cursor (.ani) from a resource number. I can use

    cursor db "cursorA.ani",0

    invoke LoadCursorFromFile,addr cursor

ok But fails to load using:

resource file:    500 CURSOR "cursorA.ani"

                      invoke LoadCursor,hInst,500

Thanks,

DougieM




dougiem

Thanks for the info, however I still have a problem. This is the code I'm using:


; .rc file
310 ANICURSORS  DISCARDABLE  "rs\\mycursor.ani"

;.data
szRescName    db "ANICURSORS",0

;.code

local dwResSize:dword
local hResource:dword
local hMem:dword
local pbCursorData:dword


invoke FindResource,NULL,310,addr szRescName
mov hResource,eax

invoke SizeofResource,NULL,eax
mov dwResSize,eax              ; size ok

invoke LoadResource,NULL,hResource
mov hMem,eax

invoke LockResource,eax
mov pbCursorData,eax             ; EAX returns same as hMem

; Fails
invoke CreateIconFromResource,pbCursorData,dwResSize,FALSE,030000h

invoke SetCursor,eax


The .ani file is ok - is there something I'm missing ?
Thanks
Dougiem

QvasiModo

This is what the article says:
QuoteBut here's the kicker – if the ANICURSORS entry is not the first resource defined in the .rc file, the code listed earlier that loads it from the resource segment will not work. Yep, that's right. Don't believe me? Transpose the two lines (or add something else above the animated cursor entry, like a string table) and watch in amazement as LoadResource fails with alacrity.
:eek Why is that?

hitchhikr

Quote
The .ani file is ok - is there something I'm missing ?

Be sure to either use WM_SETCURSOR to set it and to leave the hCursor member of your window class to 0.

Btw, the hMem variable is useless as loaded resources don't need to be free.

Quote
Why is that?

For some reasons CreateIconFromResource returns 0 if it's not, dunno why.

dougiem

CreateIconFromResource still returns 0 with the .ani file the first resource.
I'll try to write it to a temp file and load it from there until I can work out
whatas wrong.

thanks

DougieM