Hello,
I would like to load normal and animated cursors (*.cur & *.ani) from memory as I use my own virtual file system. So I can't use the LoadCursorFromFile() function. I tried to use CreateIconFromResourceEx():
// create cursor
tmp = (HCURSOR)CreateIconFromResourceEx((unsigned char*)p, size, false /* create cursor */, 0x00030000, 0, 0, 0);
But this function loads not all cursors, only 6 of my 12 cursors.
If it fails it returns NULL but GetLastError() returns also 0.
loading from .exe file as a resource works fine:
tmp = LoadCursor(hInstance, next_value);
Any other method to load cursors from memory?
Or are there some special cases/problems at cursors I have to check before loading?
Or is there something wrong with my loading method?
Best regards,
Max
I am creating static cursors in memory with the same method and it works in all cases, but I use LR_DEFAULTCOLOR|LR_DEFAULTSIZE as the last argument. Also, it depend on what are the data are you actually sending to the function. It should not be the actual .cur file, but only one of the images preceded by hotspot coordinates. So, if you can pict the desired image from the images in the .cur file, you can pass it to the function.
As for animated cursors, I have not find any function that can create them in memory and I save them to temp folder and create cursor from the saved file.
Ok, I send the complete .cur/.ani file content to the function. One .ani cursor is working with this method, all other .ani cursors not.
Some .cur cursors are working some others not.
All cursors can be opened by "RealWorld Cursor Editor 2006.1" and were created by it.
What have I to do, that all .cur files are working?
Exists a function which give me the "only one of the images preceded by hotspot coordinates" from a cursor file in memory or must it be done manually?
And why is one .ani cursor working with this method and the others not?
Are there some size or maximal number of cursor limits, which can be loaded at the same time?
Is "save them to temp folder and create cursor from the saved file" the only clean and always working solution?
This would prove the MS Windows cursor/icon API as crap.
Thank you very much for your last reply and
best regards,
Max
If you send the ordinary file to the function, I would not expect it to work at all. It is after all designed for creating an icon/cursor from a resource. And icon and cursor resources are complicated, they consist of directory and then individual images. This function works with the individual images. The .cur files contain the image directory followed by the individual images.
Finding the right place in the .cur file to send to the function must be done manually AFAIK. The is a function that works with resources, but the file is slightly different than the resource.
If you do not want to bother with the .cur files, just save them to temp folder like the .ani files and use the API that loads cursors from file. It is the fastest way (in terms of time spent on programming).
Find out how Vista icons differ from XP icons.
See how RealWorld Icon Editor handles Vista icons.