I wonder how I can correctly capture the mouse cursor when having a primary screen FullHD and a second screen 4K?
When the cursor is over the FullHD screen, I call DrawIconEx(hdcDest, 0, 0, cursorHandle, 32, 32, NULL, DI_NORMAL);, and the result is nice.
When the cursor is over the 4K screen, I call DrawIconEx(hdcDest, 0, 0, cursorHandle, 48, 48, NULL, DI_NORMAL);, but the result is blurred, not as smooth as displayed on the screen.
My actual C# code:
var hdcSrc = NativeMethods.GetWindowDC(IntPtr.Zero);
var bitmap = new Drawing.Bitmap(48, 48, PixelFormat.Format32bppRgb); using (var g = Drawing.Graphics.FromImage(bitmap))
{
var hdcDest = g.GetHdc();
NativeMethods.BitBlt(hdcDest, 0, 0, bitmap.Width, bitmap.Height, hdcSrc, 0, 0, BitBltRop.SRCCOPY | BitBltRop.CAPTUREBLT);
NativeMethods.DrawIconEx(hdcDest, 0, 0, this.cursorHandle, 48, 48, 0, IntPtr.Zero, NativeMethods.DI_NORMAL);
g.ReleaseHdc();
}
What I get at 48x48:
Blurred cursor

what I want to get at 48x48:
Smooth cursor

Does someone know how we must exactly capture the mouse cursor under Windows 11, according to the Per Monitor DPI feature?