Yes, 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. So this is exactly what you said.
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.)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.