views:

133

answers:

3

I want to get the height and width of a .cur file without look into its format.

I try to use LoadCursorFromFile() to get a HCURSOR, I suppose there is a API function to obtain the HCURSOR infos, but I find that GetCursorInfo() is not I want at all.

Is there any way to get the height and width of a HCURSOR object?

A: 

From MSDN:

The nWidth and nHeight parameters must specify a width and height that are supported by the current display driver, because the system cannot create cursors of other sizes. To determine the width and height supported by the display driver, use the GetSystemMetrics function, specifying the SM_CXCURSOR or SM_CYCURSOR value.

gwell
A: 

But cursor can be smaller then SM_CXCURSOR && SM_CYCURSOR. And hot spot can be placed in different places. How do I know real cursor size and hot-spot positon. PS Sorry for bad English

diman
+1  A: 

There is some overlap in the APIs between icons and cursors in Windows. You can call GetIconInfoEx with an HCURSOR as well as with an HICON. The structure you get back will have information about the hotspot.

I don't see a way to get the actual size. Technically, all cursor icons are SM_CXCURSOR by SM_CYCURSOR. The ones that appear smaller are actually that size, they just have a lots of transparent pixels. If you must know the apparent size, you'll have to extract the mask and scan the bits to figure out the bounding rectangle.

Adrian McCarthy
lots of help. +1
Gohan