MIOHDR v0.2.24.85 windows version hot fixed

      Comments Off on MIOHDR v0.2.24.85 windows version hot fixed

MIOHDR was released a few days ago, but I missed strange issue on Windows 10 high DPI processing. It might be belong to new version of FLTK1.4.0.6 and ghostly upgraded Windows components.

This issue maybe belong to strange calculating monitor DPI and DPI-awared GDI processing. And fixed to this issue by this way:

#ifdef _WIN32
    // Get Desktop physical height and logical height.
    HDC hdc = GetDC( NULL );
    float logicalY = GetDeviceCaps( hdc, VERTRES );
    float physicalY = GetDeviceCaps( hdc, DESKTOPVERTRES );
    ReleaseDC( NULL, hdc );

    // Let get DPI ratio for scaled --
    float dpiR = physicalY / logicalY;
    // 100% = 1.0f
    // 125% = 1.25f ...
    if ( dpiR > 1.0f )
        // High DPI with asmv3-GDIscaling element in 
        // manifest XML makes actual drawing DC to
        // double size, not actual DPI ratio when over 100%.
        // It is a reason for looks clear-graphic scaling by Microsoft.
        wdg_x *= 2;
        wdg_y *= 2;
        wdg_w *= 2;
        wdg_h *= 2;
        ndnscl = true;
#endif /// of _WIN32

It’s very simple to get multiply ratio from GetDeviceCaps of desktop handle (NULL) by VERTicalRESolution as logical height, and DESKTOPVERTicalRES as physical resolution. If dekstop DPI has multiplied to 125%, DESKTOPVERTRES returns 1080, and VERTRES returns 864. It means multiplied desktop actually has 864 pixels as high DPI resolution, and it meaning of detecting ratio of multiply easily.