How do I know the size of a HCURSOR object

前端 未结 3 530
無奈伤痛
無奈伤痛 2021-01-22 13:46

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

3条回答
  •  日久生厌
    2021-01-22 14:18

    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 a fixed size that you can get by asking the system (with GetSystemMetrics) for SM_CXCURSOR and 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.

提交回复
热议问题