CodePudding user response:
Please search before questionshttps://msdn.microsoft.com/windows/hardware/commercialize/manufacture/desktop/dpi-related-apis-and-registry-settings
CodePudding user response:
float GetScreenZoomScaleWidth ()
{
Float dbZoomScale=1.0;
HDC desktopDc=CreateDC (_T (" display "), NULL, NULL, NULL);
//Get native resolution
Int horizontalDPI=GetDeviceCaps (desktopDc LOGPIXELSX);
DbZoomScale=horizontalDPI/96.0 f;
Return dbZoomScale;
}
Float GetScreenZoomScaleHeight ()
{
Float dbZoomScale=1.0;
HDC desktopDc=CreateDC (_T (" display "), NULL, NULL, NULL);
//Get native resolution
Int verticalDPI=GetDeviceCaps (desktopDc, LOGPIXELSY);
DbZoomScale=verticalDPI/96.0 f;
Return dbZoomScale;
}
I put the monitor set to 150%, the two function called, or 96, restart the machine also not line, check the registry, found in the registration or 96, excuse me what method can solve, to get the correct value?