Make the screen DPI awareness built-in feature?

Hilfe & Unterstützung für das ISN AutoIt Studio
philpw99
Beiträge: 12
Registriert: Mi 6. Okt 2021, 02:19
Kontaktdaten:

Make the screen DPI awareness built-in feature?

Beitrag von philpw99 »

For my little project, it was strange to see the rendered GUI is 50% bigger than it's supposed to be.
It took me quite a while to find out the reason. The solution is actually easy: just put one line of code:

Code: Alles auswählen

If Not (@Compiled ) Then DllCall("User32.dll","bool","SetProcessDPIAware")
in the "GUI properties -> Extra code before the GUI"
This way it will make my program looks the same size in my 4k screen.
Now maybe this code should be integrated into ISN AutoIt Studio? Once you choose the "Enable High DPI mode", this line of code should be run by default. This way ISN newbies will not be surprised to see a much larger rendered GUI.
Benutzeravatar
ISI360
Administrator
Beiträge: 322
Registriert: Fr 11. Okt 2013, 13:06
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von ISI360 »

Hi

Thanks for your feedback.
Since there is no "standardized" way to make an AutoIt App DPI aware, i think it´s the best way to let the user choose.
And "SetProcessDPIAware" is only the first step on a full DPI aware App. You have to scale every GUI, every control in your app to the DPI system value to make it look as it should. (The ISN itselfe does this all too..)

But maybe a "snippets" section, or something similar would be a nice edition for a future update. Here we could place such reccomendations for a DPI aware GUI.
philpw99
Beiträge: 12
Registriert: Mi 6. Okt 2021, 02:19
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von philpw99 »

Just my humble opinion, your program makes GUI programming easy, so why not make the DPI awareness easy as well?
Right now it's very easy to make a DPI aware program in ISN, just check one setting, then compile it. I don't even need to know what code you have put in. It just works beautifully.
However, when it comes to testing and debugging, it's not so elegant. Once hit F5, I am staring at a much bigger GUI than it's supposed to be. It creates confusions like: am I using the right setting? Is my size number correct?...etc. Only after compiling it to an exe, I found my worries were not necessary. The layout of final exe's GUI is exactly what's supposed to be.
Therefore, even you have make the effort to support high DPI in the final compiled exe, the testing and debugging experience are not so good. And all it takes to fix it is just one extra line of code. So this is why I ask here to make this line of code built-in for high dpi apps. If this code were built-in, I wouldn't have been so confused in the beginning.
Benutzeravatar
ISI360
Administrator
Beiträge: 322
Registriert: Fr 11. Okt 2013, 13:06
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von ISI360 »

There is already such a "switch" for compiling an .exe via the AutoIt Wrapper Directives: https://www.autoitscript.com/autoit3/sc ... lable.html

If you set #AutoIt3Wrapper_Res_HiDpi=Y into your script, the compiler auto set´s your app HighDPI compatible when compiling.

The only reason I use the "DllCall("User32.dll","bool","SetProcessDPIAware")" stuff is, that these directives ONLY work for .exe files. And the ISN works internaly with .a3x files, so the DllCall is the only way to make au3/a3x files make DPIAware.
philpw99
Beiträge: 12
Registriert: Mi 6. Okt 2021, 02:19
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von philpw99 »

I am so sorry I have to keep arguing with this, because I think you really need to understand what I meant.
It's great that you already put in the high DPI option in the setting, and already make the compiled exe high DPI aware. You already did 90% of the work.
But the reason I keep mentioning this DllCall is that if I run my a3u script by hitting "F5", on my 4k monitor the GUI looks way too big. This DllCall will make the testing and debugging look normal. Here is a picture showing before the DllCall:
Bild
Here is the picture after the DllCall:
Bild

So you see? There is a huge difference when doing debugging in ISN studio with this DllCall. This is why I keep raising this issue to you, although I am really appreciate all your effort to make this program.
Thank you so much !
Benutzeravatar
ISI360
Administrator
Beiträge: 322
Registriert: Fr 11. Okt 2013, 13:06
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von ISI360 »

I understand your problem here. And testing via F5 is a good argument for an automated integration.
But the ISN cant inject some code lines on the fly, it just can made a copy of the source file with some modifications (for example the added DllCall).
(Not such a fan of this methode)

I am thinking what could be a easy solution for this. Maybe a simple hint popup when testing and a HighDPI Monitor is detected to manually insert the DllCall stuff in the mainfile?
philpw99
Beiträge: 12
Registriert: Mi 6. Okt 2021, 02:19
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von philpw99 »

Great you are considering it. I think the solution is easy. If someone in the settings, "Enable High DPI ...", then if that's a high dpi screen, then the program will automatically put that line of code in the "Before GUI..." script with quotes to explain what that is. Then the user can manually delete the preset code, but at least they will not be surprised to see a much large GUI.
Benutzeravatar
ISI360
Administrator
Beiträge: 322
Registriert: Fr 11. Okt 2013, 13:06
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von ISI360 »

I don´t want to include the dll call in the GUI. You only need the call one single time at startup, not for every single gui.
So the way to go is to include the DllCall in the mainfile of the script.
Benutzeravatar
ISI360
Administrator
Beiträge: 322
Registriert: Fr 11. Okt 2013, 13:06
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von ISI360 »

I will include this feature in the next version in this way:
There will be a new checkbox in the "Create new project" dialog to make the new project high dpi aware...which will include the DllCall Line directly in the new created project.
This checkbox will be checked by default. In this way it´s directly included in the mainfile when a new project is created.
philpw99
Beiträge: 12
Registriert: Mi 6. Okt 2021, 02:19
Kontaktdaten:

Re: Make the screen DPI awareness built-in feature?

Beitrag von philpw99 »

Thank you so much for including it ! Looking forward to your next awesome version! :D
Antworten