Jump to content

"GuiCtrls_HiDpi" (UDF in progress)


argumentum
 Share

Recommended Posts

I should not spend time on this as I need to attend to my work. I should have been a painter. Then again, when you paint for a living you find your self's inspiration cut short due to clients demands. I should be a child, and with enough time I'm told I'm likely to go back to have those early childhood events reoccur. But I'm going off topic.

If the user has monitors in X multipliers its a good setup for GUIs, say 100% here and 200% there. But if you have 225% there, then your code leaves you with a decimal.
Having a decimal forces to either round, floor or ceiling the number. I left it to AutoIt to decide by changing the resizing/anchoring and going back and forth, and on that condition, it does not look good. There are no partial pixels.

Debugging for me is to expose the code to any environment that would be unexpected and actively abuse it until it brakes.
Since this UDF would be used in odd circumstances, it should be coded to behave on those conditions too. I even attend to conditions a newbie would mess up and not have the function brake the script in say, it should return an array and on @error, it still returns an array, as an array is expected because most newbies here don't check for the error flag and it would crash their code. I may even be offered a Nobel Price, given my contributions to humanity. But I'm going off topic.

It works but no cigar. The last thing we need in this community is to offer something with a promise, but didn't take this or that into consideration. 100 caveats.
Then the AutoIt sucks because it does not work, even though it was the UDF.

Anyone testing this, please do try to brake it. And if you successfully broke it, fix it. ( and share the code for the rest of us copy'n'paste kind of people. ) 

Edited by argumentum
spelling

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • 6 months later...
42 minutes ago, simplercoder000 said:

but I'm running into this error:

Never tried in Win7. The error comes from _HiDpi_GetDpiForWindow() that in itself is adaptation from https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1521526 .

Replace this and let me know.

;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow
Func _HiDpi_GetDpiForWindow($hWnd = Default)
    Local $iErr, $iExt, $aResult, $gui = 0
    If $hWnd = Default Then $gui = GUICreate("")
    Local $aResult = DllCall("user32.dll", "uint", "GetDpiForWindow", "hwnd", ($gui ? $gui : $hWnd)) ;requires Win10 v1607+ / no server support
    $iErr = @error ; adaptation from https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1521526
    $iExt = @extended ; were the original code can be found.
    If $gui Then GUIDelete($gui)
    If $iErr Or Not IsArray($aResult) Then Return SetError($iErr + Int($iErr ? 0 : 100), $iExt, 96)
    Return $aResult[0] ; should be retutning an array[2] 
EndFunc   ;==>_HiDpi_GetDpiForWindow

..an oversight of my copy and paste. I should have used If $iErr ... .

Edited by argumentum
better code ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

3 minutes ago, simplercoder000 said:

but the DPI issue are still there :(

I don't have a Win 7 to have a go at it :(
The error was fortunately easy to correct but to see on a screen, I'll need to have a Win 7 to look at. It'll take me a few days to investigate. Then again, if  _HiDpi_GetDpiForWindow() failed it means that the OS does not recognize it.

@UEZ, help :baby:

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

tho in the function notes it has as reference https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow

It say on the bottom of the screen:
Minimum supported clientWindows 10, version 1607 [desktop apps only]
Minimum supported serverWindows Server 2016 [desktop apps only]

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

8 minutes ago, argumentum said:

tho in the function notes it has as reference https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow

It say on the bottom of the screen:
Minimum supported clientWindows 10, version 1607 [desktop apps only]
Minimum supported serverWindows Server 2016 [desktop apps only]

Searching in the forum again I back to this thread here:

Adding this line into the example script seems to enable the High DPI mode:

DllCall("User32.dll", "bool", "SetProcessDPIAware")

I just added somewhere before the GUI loads

 

Now the example has become DPI awareness but the GUI is unsorted well !

GuiCtrls_HiDpi.Example_blurriness_fuzziness_2.png

Link to comment
Share on other sites

1 minute ago, simplercoder000 said:

Adding this line into the example script seems to enable the High DPI mode

...yes, it's a pickle. This UDF am putting together is just helper functions for the rest of the code that I scrapped off the forum.
Its "GuiCtrls_HiDpi" (UDF in progress). Unfortunately, right now, I'm really busy with work. I'll have a deep look at it as soon as I can install Win7 and give it full attention.

Do pardon. I thought that the stable version was sufficiently functional.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

13 minutes ago, simplercoder000 said:

but the GUI is unsorted well !

for now, play with

EndFunc   ;==>_HiDpi_GUICreate <<<< righ after this line add
GUISetFont(4)  ; add this. Change the font to something functional ?

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...