4.5 Cursor Resources
Cursor resources are very much like icon resources. They are formed in groups with the components preceding the header. This header also employs a fixed-length component index that allows random access of the individual components. The structure of the cursor header is as follows:
[Resource header (type = 12)]
struct CursorHeader {
WORD wReserved; // Currently zero
WORD wType; // 2 for cursors
WORD cwCount; // Number of components
WORD padding; // Filler for DWORD alignment
};
The next portion is repeated for each component resource, and starts on a DWORD boundary.
struct ResourceDirectory {
WORD wWidth;
WORD wHeight;
WORD wPlanes;
WORD wBitCount;
DWORD lBytesInRes;
WORD wNameOrdinal; // Points to component
WORD padding; // Filler for DWORD alignment
};
Each cursor component is also similar to each icon component. There is, however, one significant difference between the two: cursors have the concept of a "hotspot" where icons do not. Here is the component structure:
[Resource header (Type = 1)]
struct CursorComponent {
short xHotspot;
short yHotspot;
}
[Monochrome XOR mask]
[Monochrome AND mask]
These masks are bitmaps copied from the .CUR file. The main difference from icons in this regard is that cursors do not have color DIBs used for XOR masks like cursors. Although the bitmaps are monochrome and do not have DIB headers or color tables, the bits are still in DIB format with respect to alignment and direction. See the SDK Reference for more information on DIB formats.