-
August 22nd, 2005, 05:47 PM
#1
Save cursor in a file (.CUR file format)?
Hi everyone:
Does anyone know how to save a cursor in a file? Any links regarding .CUR file format?
Any info will be appreciated...
-
August 22nd, 2005, 07:36 PM
#2
Re: Save cursor in a file (.CUR file format)?
I am not aware of any way to save to a cur given a cursor handle.
But, here is some info on the .cur format.
http://www.wotsit.org/
Type in cur in the search box and you will see 4 results with the file format specifications.
-
August 23rd, 2005, 06:35 AM
#3
Re: Save cursor in a file (.CUR file format)?
Originally Posted by dc_2000
Hi everyone:
Does anyone know how to save a cursor in a file? Any links regarding .CUR file format?
Any info will be appreciated...
if you dont find anything over the net ( which i doubt ) you can always find it yourself.
- create lets say a white cursor in the MSDV
- export it to file
- write program that read the whole bytes to memory find out what is the Data of the cursor ( white pixels ) and you will stay with the header. or other data you need to specify.
- now you can try to create it yourself ( just replace color ) and open it in msdv see if its valid format.
just an idea you can figure it out yourself with some testing.
Cheers
-
August 23rd, 2005, 07:03 AM
#4
Re: Save cursor in a file (.CUR file format)?
There is the LockResource() function. It normally works with a handle you get using FindResource() and LoadResource(). But maybe you are lucky and it also works with a HCURSOR handle. I would at least try it by simply casting it to HGLOBAL. Then write the buffer to a file and see if it shows up as a cursor in explorer.
Please don't forget to rate users who helped you!
-
August 23rd, 2005, 01:08 PM
#5
Re: Save cursor in a file (.CUR file format)?
Hey guys -- thank you everyone. I think I found a solution. (kirants clued me in) There's a good article in MSDN and an example called IconPro (http://msdn.microsoft.com/library/en...msdn_icons.asp).
Yes, you'd say this is about icons, but at the end it says, "Cursors, in Win32, are very similar to icons". There's one data member in the header of a .CUR file that is different from the .ICO file.
I haven't tried it yet, but here's how it should work:
(1) Use GetIconInfo with an HCURSOR:
Code:
ICONINFO ii;
if(!GetIconInfo(hCursor, &ii) || ii.fIcon != FALSE)
{
//Error, handle is not a cursor, or is a bad one
}
(2) Then inspect two members of ICONINFO: hbmMask and hbmColor which are two bitmaps for a mask and color image of a cursor. Both are regular bitmaps, so we can use GetObject to retrieve all the info for the header of .CUR file (which format you can find in that MSDN article above), and GetDIBits to retrieve graphic bits.
The only thing that first confused me was the fact the HCURSOR handle carries information only about cursor currently displayed and doesn't have any other images the cursor might have in a resource file. Evidently when it is loaded by LoadCursor or LoadImage all of them are discarded and not stored in memory. (As well as icons, by the way.)
As for using HCURSOR as HGLOBAL, I tried it and it didn't work. I'm sure there is a low-level kernel API that can take a graphics handle and transform it into memory lock, but I haven't delved into it. If you find it, please post it here
I also wanted to use a guessing method suggested by golanshahar, but it's not as easy as it sounds.
Thank you everyone again!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|