5

On a machine with a high DPI monitor connected when I try to get the cursor (though GetIconInfo or GetIconInfoEx) I get an HBITMAP which is 3 times the normal size.

Is there a way to get a cursor normal size so that I don't have to resize it myself?

I get artifacts when I resize it my self

Since it was marked as duplicate question (Load cursor with certain resolution), let me explain why it's not:

First of all I am not loading any cursor. I'm using the system's default. Also when I query the system for the cursor size, whether the cursor is on a hi-DPI or normal-DPI monitor I always get 64 pixels, the same value. Also I get the same value whether I have from control panel the monitor's scaling factor to 100% or more. Also the same value I get whether or not I have small, medium or large cursor (from control panel mouse ease of access)

General Grievance
  • 4,555
  • 31
  • 31
  • 45
hamlatzis
  • 81
  • 10

1 Answers1

0

You do not state what normal size refers to, so I'm going to assume, that it's the cursor size that the hardware mouse pointer is displayed at (32×32 at 96 DPI 100 % scale).

Dimensions of the bitmap returned by GetIconInfo (and the cursor itself) is affected by the DPI-scale specified in the control panel, which can be depending on Windows version same for the whole system or vary between monitors. Additionally the bitmap size is also affected by whether or not your application is marked as DPI-aware, otherwise Windows scales everything for the application.

DPI scale Mouse cursor size DPI aware GetIconInfo bitmap
100 % 32×32 - 32×32
150 % 48×48 No 72×72
150 % 48×48 Yes 48×48
200 % 64×64 No 128×128
200 % 64×64 Yes 64×64
Ai4rei
  • 11
  • 3
  • This is not entirely correct. GetIconInfo will return a bitmap sized for the primary display only. If your main display is 150%, but the cursor is on a 100% secondary monitor, you'll get an incorrect 48x48 bitmap instead of 32x32. You need to check the DPI of the monitor with `GetDpiForMonitor `, then use `GetSystemMetricsForDpi` to get the proper icon size. You may need to also scale this by the "cursor magnification" settings from accessibility `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Accessibility`. Then you need to use `LoadImage` to grab the correctly sized cursor image. – caesay Sep 22 '22 at 12:53