Silverfrost Forums

Welcome to our forums

Problem with text scaling under Windows 10

29 Jul 2019 1:18 (Edited: 31 Jul 2019 9:04) #24109

Dear all,

normally for regognicing if a user uses a text scalling I have used method “CLEARWIN_INFO@( 'SYSTEM_FONT_HEIGHT' )” until now. It seems that under Windows 10 the function returns value 16 always. In this case I can’t distinguish if a text scallig is used or not.

Does someone have observed the same behavior and can tell me a workaround?

I work with FTN95 Ver. 7.10.0

29 Jul 2019 2:25 #24110

The result of this call is based on a Windows API call to GetStockObject(SYSTEM_FONT). The Microsoft help says 'By default, the system uses the system font to draw menus, dialog box controls, and text'.

It also says: 'It is not recommended that you employ this method to obtain the current font used by dialogs and windows. Instead, use the SystemParametersInfo function with the SPI_GETNONCLIENTMETRICS parameter to retrieve the current font.'

Maybe I should add a new CLEARWIN_INFO@ value that uses the Microsoft recommended method of retrieving the current font.

29 Jul 2019 2:38 #24111

Next strange behavior:

My desktop resolution is 1920*1080. When Scalling is set to 125%

CLEARWIN_INFO@('SCREEN_WIDTH') CLEARWIN_INFO@('SCREEN_DEPTH')

return a resulution 1536864. Under Windows 7 I get resolution 19201080.

It looks for my like Windows 10 is using a complete different scalling mechanism? Like a zoom effect?

29 Jul 2019 3:14 #24112

If you do the necessary research you will find that MS have been at work tinkering with this scaling business, to the confusion of all of us.

When you use the Clearwin+ method of spacing out controls as a function of the average character size, everything always fits - except things like icons and bitmaps in toolbars, which get weird spacing.

Those increased dpi settings are for physically small displays like tablets, and for very high dpi displays. Since windows tablets are utter rubbish, and high dpi displays - like electric cars - are there to let rich idiots look down their noses at us plebs, a good strategy is to sample the logical dpi, and if it isn't 96, to tell the would-be user that you don't support it!

Eddie

31 Jul 2019 9:09 #24113

I tried to use SPI_GETNONCLIENTMETRICS this way. Is that okay?:

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, 'user32.lib')    

void main()  
{     
    BOOL fResult;
    NONCLIENTMETRICS  ncm;
    
    fResult = SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
                                   sizeof(NONCLIENTMETRICS),
                                   &ncm,
                                   0);                                   
    if( fResult )     
    {
    	
    }  
}

Are the results good? I have no idea how I recognize scaling 125% is set...

https://i.imgur.com/MOfpG6j.png

31 Jul 2019 10:11 #24115

This solution provides the expected scaling result 100, 125, 150:

    HDC desktopDc;
    desktopDc = GetDC(NULL);    
    int virtualWidth = GetDeviceCaps(desktopDc,  HORZRES);
    int physicalWidth = GetDeviceCaps(desktopDc, DESKTOPHORZRES);
    int dpi = (int)(96.0 * physicalWidth / virtualWidth);
    int sf = 100.0 / 96.0 * dpi;
31 Jul 2019 12:33 #24117

dgurok

I had already looked at the first of your two approaches and it didn't seem to provide anything useful.

Your second approach looks more hopeful.

Please login to reply.