DigDeep Posted February 21, 2018 Share Posted February 21, 2018 (edited) Hi, If someone can help me with setting my GUI correctly please. I have set my machine with 125% DPI. If I am changing the DPI settings from 125% - 150%, the GUI goes too huge in size. I even tried getting the DPI settings in the GUI but it's still the same. Is there a way to set the GUI and all the lables / buttons inside it to not change (Fixed) at all even though screen DPI will change from 100 / 125 / 150...? I am posting both with and without DPI settings GUI. Without DPI #RequireAdmin #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### $Form1 = GUICreate("Form1", 1255, 646, -1, -1) $Label1 = GUICtrlCreateLabel(" Label1 ", 976, 24, 66, 20, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Verdana") $Label2 = GUICtrlCreateLabel("Label2", 8, 701, 36, 17) $Label3 = GUICtrlCreateLabel("Label3", 609, 250, 270, 205) $Pic1 = GUICtrlCreatePic("", 698, 263, 100, 75) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd With Auto DPI expandcollapse popup#RequireAdmin #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> ; DPI #include <GuiMenu.au3> ; DPI Func _GetDPI() Local $hDC = _WinAPI_GetDC(0) Local $DPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY) _WinAPI_ReleaseDC(0, $hDC) Select Case $DPI = 0 $DPI = 96 Case $DPI < 84 $DPI /= 105 Case $DPI < 121 $DPI /= 96 Case $DPI < 145 $DPI /= 95 Case Else $DPI /= 94 EndSelect Return Round($DPI, 2) EndFunc ;==>_GetDPI $DPI = _GetDPI() #Region ### START Koda GUI section ### $Form1 = GUICreate("Form1", 1255 * $DPI, 646 * $DPI, -1 * $DPI, -1 * $DPI) $Label1 = GUICtrlCreateLabel(" Label1 ", 976 * $DPI, 24 * $DPI, 66 * $DPI, 20 * $DPI, $SS_RIGHT) GUICtrlSetFont(-1, 10, 400, 0, "Verdana") $Label2 = GUICtrlCreateLabel("Label2", 8 * $DPI, 701 * $DPI, 36 * $DPI, 17 * $DPI) $Label3 = GUICtrlCreateLabel("Label3", 609 * $DPI, 250 * $DPI, 270 * $DPI, 205 * $DPI) $Pic1 = GUICtrlCreatePic("", 698 * $DPI, 263 * $DPI, 100 * $DPI, 75 * $DPI) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited February 21, 2018 by DigDeep Link to comment Share on other sites More sharing options...
teddybear69 Posted March 6, 2018 Share Posted March 6, 2018 Did you create your GUI at 125% or at 100%? If you created your GUI at 125% your _GetDPI() is not compensating properly for it is assuming you created your GUI at 100%. Link to comment Share on other sites More sharing options...
BrewManNH Posted March 6, 2018 Share Posted March 6, 2018 You could use the directive in AutoIt3Wrapper to compile for high DPI #AutoIt3Wrapper_Res_HiDpi= ;(Y/N) Compile for high DPI. Default=N No idea if that works or not, but it's something to try. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
DutchCoder Posted March 7, 2018 Share Posted March 7, 2018 Is this question not simply solved by GUISetFont ? Link to comment Share on other sites More sharing options...
DigDeep Posted March 14, 2018 Author Share Posted March 14, 2018 @teddybear69, I tried re-creating my application at 100%,125% and 150% both at Full HD & 4K resolutions display. @BrewManNH, I already had the HiDPI declared. I even tried to re-create removing the HiDPI. Using both the above options the application is running fine if at 100% or 125% but as soon as the screen is changed to 150%, the GUI goes completely outside the screen panels. For now, I have removed DPI settings completely. Link to comment Share on other sites More sharing options...
UEZ Posted March 14, 2018 Share Posted March 14, 2018 Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> ; DPI #include <GuiMenu.au3> ; DPI #include <GDIPlus.au3> Global $aDPI = _GDIPlus_GraphicsGetDPIRatio() ConsoleWrite($aDPI[0] & @CRLF) #Region ### START Koda GUI section ### $Form1 = GUICreate("Form1", 1255, 646, -1, -1) $Label1 = GUICtrlCreateLabel(" Label1 ", 976, 24, 66, 20, $SS_RIGHT) GUICtrlSetFont(-1, 10 * $aDPI[0], 400, 0, "Verdana") $Label2 = GUICtrlCreateLabel("Label2", 8, 701, 36, 17) GUICtrlSetFont(-1, 8.5 * $aDPI[0]) $Label3 = GUICtrlCreateLabel("Label3", 609, 250, 270, 205) GUICtrlSetFont(-1, 8.5 * $aDPI[0]) $Pic1 = GUICtrlCreatePic("", 698, 263, 100, 75) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 0) Local $iDPI = $aResult[2] _GDIPlus_GraphicsDispose($hGfx) Local $aResults[2] = [$iDPIDef / $iDPI, $iDPI / $iDPIDef] _GDIPlus_Shutdown() Return $aResults EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
DigDeep Posted March 14, 2018 Author Share Posted March 14, 2018 thanks @UEZ. Will try once and let you know. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now