Search code examples
windowswinapigdi

Load cursor with certain resolution


I have two cursor resources. The first one [IDC_CURSOR1] contains three different image types:

  • 32x32, 24 bpp
  • 48x48, 24 bpp
  • 64x64, 24 bpp

The second one [IDC_CURSOR2] contains only one:

  • 48x48, 24 bpp

If I'm calling LoadCursor(hInst, IDC_CURSOR1) it always loads 32x32 version and I was unable to find the way to load 48x48 or 64x64 version. In second case it loads 48x48 icon (because there is no other version), but it scales it down to 32x32.

How can I load a cursor with other than 32x32 resolution?

BTW: I tried to change DPI because according to msdn it should automatically load higher resolution cursor in higher dpi, but it doesn't.

Thank you!


Solution

  • Call LoadImage passing IMAGE_CURSOR and specifying the desired dimensions.

    Cursor = (HCURSOR)LoadImage(hinst, IDC_CURSOR1, IMAGE_CURSOR, 64, 64, LR_DEFAULTCOLOR);