Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: n = WinSetProcessDPIAware()

  1. #1
    Senior Member catventure's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    643
    Rep Power
    84

    n = WinSetProcessDPIAware()

    I saw that in the latest version of thinbasic there is a new function


    n = WinSetProcessDPIAware()


    My TAB adventure program was made using thinbasic core 1.9.16.17. for backwards compatibility with Windows XP and above.


    A user of my program tested on his system and reported that even on a low end laptop with win 10 and a full HD screen (1920 x 1080) there were readability problems due to display size of the TAB app.


    The text in the editor where you type the info for location text is literally unreadable it is so small. And the game text in the runner is literally unreadable and too small.


    TAB seems very fast and the editor looks awesome, for what I can see. Unfortunately the text aspect of TAB is not compatible with modern systems. A shame, because otherwise TAB appears awesome in reading through the features.


    it is difficult trying to find something that still works and that works with modern systems and is DPI aware and will display properly on modern systems."

    Since I cannot use the new DPI function available in the new thinbasic version, what equivalent code would I need to include to update my program so that it will be dpi (dots per inch) aware and automatically adjust to the screen resolutions and monitor displays of the more modern high end setups of today?


    It would be great if in fact possible to do? How would I achieve it - and whereabouts would I position the code in my program listing?
    (I'm assuming it would need to be set as a default before the program creates any Windows)


    I am only a hobbiest programmer and after reading the microsoft link in the thinbasic help file for the new function I do not understand or see how I would begin to implement it correctly into my code.


    MS documentation at:
    https://learn.microsoft.com/en-us/wi...rocessdpiaware



    I would really like it if my program could be usable on as many Windows rez as possible. Seems later setups have changed gradually over the years to higher settings than the default standard 96dpi


    Regards,
    catventure/Philip.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    58
    Posts
    8,843
    Rep Power
    10
    Ciao,

    you can try the following call that tells the operating system that your application is not dpi aware

    https://learn.microsoft.com/en-us/wi...ssdpiawareness

    'Declare Function SetProcessDPIAware Lib "user32.dll" Alias "SetProcessDPIAware" () As Long
    %PROCESS_DPI_UNAWARE = 0
    %PROCESS_SYSTEM_DPI_AWARE = 1
    %PROCESS_PER_MONITOR_DPI_AWARE = 2
    Declare Function SetProcessDpiAwareness Lib "Shcore.dll" Alias "SetProcessDpiAwareness" (byval PROCESS_DPI_AWARENESS  as dword) As Long
    SetProcessDpiAwareness(%PROCESS_DPI_UNAWARE)
    
    If it works, you can add a parameter to your application to call or not this function depending on some circumstances.

    Let me know
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Senior Member catventure's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    643
    Rep Power
    84
    Hi Eros,


    Thank you for your response.


    I placed this code into my program listing near the top and my program ran as normal.


    %PROCESS_DPI_UNAWARE = 0
    %PROCESS_SYSTEM_DPI_AWARE = 1
    %PROCESS_PER_MONITOR_DPI_AWARE = 2
    Declare Function SetProcessDPIAware Lib "user32.dll" Alias "SetProcessDPIAware" () As Long
    


    The other bit of code you supplied did not


    %PROCESS_DPI_UNAWARE = 0
    %PROCESS_SYSTEM_DPI_AWARE = 1
    %PROCESS_PER_MONITOR_DPI_AWARE = 2
    Declare Function SetProcessDpiAwareness Lib "Shcore.dll" Alias "SetProcessDpiAwareness" (byval PROCESS_DPI_AWARENESS  as dword) As Long
    SetProcessDpiAwareness(%PROCESS_DPI_UNAWARE)
    

    (Invalid. Didn't recognise Lib "Shcore.dll)


    I understand that If the dpi setting is >96 then no doubt it will be required to make the TAB program dpi aware.


    This could mean devising code to take into account the different versions of windows that might be running the program....?


    I also accept that some GUI elements and fonts might need to be scaled somehow - so might need to get the current desktop dpi ratios from the monitor...


    Sounds though like it might be a little complicated - but maybe possible to implement this.

    How and what code do I need to do it? Any help suggestions would be great.


    If TAB is not dpi aware then Windows will probably scale it resulting in smaller gui, images and text.


    When I created my program all those years ago I did not envisage this problem of visibility or usability occurring on the high end monitor resolutions which are slowly becoming default on newer setups nowadays.




    Thanks ever so much,
    catventure/Philip.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  4. #4
    Senior Member catventure's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    643
    Rep Power
    84
    Well, I've still not been able to solve this yet - but I asked Grok AI on X (twitter) about it as it appears to understand thinbasic and can write thinbasic code for you in certain cases.... (I was really impressed with that, Eros)

    Seems complicated to my mind and am not sure how to code that. I really want the TAB to kind of automatically proportionally scale all the windows and controls to adjust to the resolution of the screen/monitor it is being displayed on so that it does not become too small or unusable on some modern hi-end systems where the dpi is quite high.

    Does anyone know have an elegant solution how? Even if it makes the app or text look a little blurry?

    Best wishes,
    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    58
    Posts
    8,843
    Rep Power
    10
    On what operating system do you bundled TAB script?
    I mean, what OS is your thinBasic 1.9.16.17 running?

    Maybe I have an idea.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    Senior Member catventure's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    643
    Rep Power
    84
    Dear Eros,


    I use my desktop (32bit ; Windows Vista) or my laptop (64bit; Windows 10) for uploading and bundling (usually my desktop) I turn my virus checker OFF before bundling the exe's as it can interfere - but you already know about that, I think.


    Laptop
    ======
    OS Name Microsoft Windows 10 Home
    Version 10.0.19045 Build 19045
    OS Manufacturer Microsoft Corporation
    System Type x64-based PC
    Processor Intel(R) Celeron(R) CPU N2840 @ 2.16GHz, 2159 Mhz, 2 Core(s), 2 Logical


    Desktop
    =======
    OS Name Microsoft® Windows Vista™ Home Premium
    Version 6.0.6002 Service Pack 2 Build 6002
    OS Manufacturer Microsoft Corporation
    System Manufacture Compaq-Presario
    System Type X86-based PC
    Processor Intel(R) Pentium(R) Dual CPU E2140 @ 1.60GHz, 1600 Mhz, 2 Core(s), 2 Logical Processor(s)
    32bit


    I use 1.9.16.17 on my laptop or desktop and bundle through thinAir so TAB hopefully run on all Windows from XP and above.

    On desktop with Vista my screen rez is 1280x960 pixels and everything looks ok how I want it so I tend to use the program from there.

    On laptop with win10 the rez is 1266x768 and displays ok. However app window is smaller... looks about half the size.

    Regards,
    Phil. (catventure}
    Last edited by catventure; 08-06-2025 at 20:33.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    58
    Posts
    8,843
    Rep Power
    10
    OK thanks.

    The idea is to:
    1. have a thinBasic version 1.14.x able to work on Windows 7 as a minimum OS
    2. have a thinBundle able to create executables compatible with Windows 7 and possibly Win XP ... but it will depends on which modules are used by the script


    Number 1 I've already done

    Number 2 ... I'm working on
    I need to find all the functionalities I've used, which are not compatible with old OSs and see if I can avoid to use them
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #8
    Senior Member catventure's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    643
    Rep Power
    84
    Hello Eros,
    That sounds an interesting direction especially if it can help with solving this issue.
    I hope your ideas can be implemented to make this so as I would like the TAB to run on 32bit and 64bit systems.
    I realise some recoding of the TAB program might be called for but hopefully this can be accomplished without too much trouble.

    Module usage:
    UI
    OS
    FILE
    TBASS
    GDIP

    Regards,
    Philip/catventure.
    Last edited by catventure; 09-06-2025 at 17:07.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    58
    Posts
    8,843
    Rep Power
    10
    Updated thinBasic 1.14.0.0 Beta here:
    https://www.thinbasic.com/community/...ll=1#post97012

    This version and produced bundled executables should work from Windows 7 to Windows 11
    Produced bundled executables using UI should automatically scale in high DPI systems at runtime for most of the controls.

    I'm working in order to let bundled executables to be used under Windows XP too.
    I need to dynamically manage BCRYPT.DLL loading that is not present in Windows XP
    Last edited by ErosOlmi; 10-06-2025 at 18:08.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  10. #10
    Senior Member catventure's Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    643
    Rep Power
    84
    Hi Eros,
    I gave it a try.
    I uninstalled 1.9.16.17 on my Laptop windows 10 and downloaded and installed your new beta 1.14.0.0 zip version successfully.
    Is there something not yet working in thinAir? I could not load any sampleprograms or my own programs into the thinAir editor. It lists the program name in the tab but there is no program listing visible - just a grey blank screen... so cannot view or edit code.
    The offline help file and other things seems working OK
    Phil.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

Page 1 of 2 12 LastLast

Members who have read this thread: 5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •