pixelsearch Posted July 25 Share Posted July 25 (edited) Hi everybody The purpose of this post is to indicate how simple it is to change your "too small" Gui for a bigger one, resizing (or not) the associated controls font. 1) SampleControls.au3 The original example is found in AutoIt package (subfolder ..\Example\GUI) and displays its GUI like this : 2) "SampleControls (resizable Gui).au3" [ based on SampleControls.au3 ] If you want to enlarge the Gui because it appears too small depending on your screen resolution, here are the changes to apply, where the Gui is resizable but the control fonts are unchanged : ; Added ; ----- #include <StaticConstants.au3> ; center the label control #include <WindowsConstants.au3> ; $WS_OVERLAPPEDWINDOW Opt("GUIResizeMode", $GUI_DOCKAUTO) ;0 = (default) keep default control resizing , <1024 = any type of resizing ; Modified ; -------- ; GUICreate("Sample GUI", 400, 400) GUICreate("Sample GUI", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW) ; GUICtrlCreateLabel("Green" & @CRLF & "Label", 350, 165, 40, 40) GUICtrlCreateLabel("Label", 350, 165, 40, 40, BitOr($SS_CENTERIMAGE, $SS_CENTER)) 3) "SampleControls (resizable Gui & fonts).au3" [ based on "SampleControls (resizable Gui).au3" ] If you want to enlarge the Gui AND resize the controls font so they appear bigger, here are the changes to apply : ; Added ; ----- Global $hGUI, $iGUIInitSizeW = 400, $iLast_DummyControl $iLast_DummyControl = GUICtrlCreateDummy() ; just before GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SIZE, "WM_SIZE") Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI Then Local Static $iFontSize_Old = 0 Local $iParentW = BitAND($lParam, 0xFFFF) ; low word (new width of the client area) ; Local $iParentH = BitShift($lParam, 16) ; high word (new height of the client area) Local $iFontSize = Int(2 * (.5 + (8 * $iParentW / $iGUIInitSizeW))) / 2 If $iFontSize_Old <> $iFontSize Then For $i = 3 To $iLast_DummyControl - 1 ; 1st control in GUI is always 3 GUICtrlSetFont($i, $iFontSize) Next $iFontSize_Old = $iFontSize EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE ; Modified ; -------- ; GUICreate("Sample GUI", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW) $hGUI = GUICreate("Sample GUI", $iGUIInitSizeW, 400, -1, -1, $WS_OVERLAPPEDWINDOW) Below, a bolder font appears when more resizing is applied to the GUI : I just tried all this on a personal script and the results looked fine, hope it will be same for you. Big thanks to @Melba23 for his script, found here Mods, I don't know where this post should be placed on the Forum. Please move it if you think its place isn't the appropriate one, thanks. Edited July 25 by pixelsearch added 4th pic Danyfirex and ptrex 2 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