Moderators Melba23 Posted July 13, 2021 Moderators Share Posted July 13, 2021 SharkyEXE, It works perfectly for me: #include <StaticConstants.au3> #include "StringSize.au3" Const $iGUIWidth = 800 Const $iGUIHeight = 200 $hGui = GUICreate("", 800, 200) GUISetFont(10) GUISetState() For $iFontSize = 10 To 20 WinSetTitle($hGui, "", "FontSize = " & $iFontSize) ; Get the size of label needed to hold the text $aRet = _StringSize("Both vertically" & @CRLF & "and horizontally centered", $iFontSize) ; Add a bit to cater for Windows sizing eccentricity $aRet[2] += 5 ; Work out where it needs to be on the GUI $iX = ($iGUIWidth - $aRet[2]) / 2 $iY = ($iGUIHeight - $aRet[3]) / 2 ; And create it $cLabel = GUICtrlCreateLabel("Both vertically" & @CRLF & "and horizontally centered", $iX, $iY, $aRet[2], $aRet[3], $SS_CENTER) GUICtrlSetFont($cLabel, $iFontSize) Sleep(1000) GUICtrlDelete($cLabel) Next M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
SharkyEXE Posted July 14, 2021 Share Posted July 14, 2021 (edited) Melba23 Hello I run your script Please, see pictures, very-very need fix for height Edited July 14, 2021 by SharkyEXE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2021 Moderators Share Posted July 14, 2021 SharkyEXE, Quote very-very need fix As I have tried to explain several times, the dimensions returned by the StringSize function are those given by the Windows API call to measure the passed characters in a specified font, size and type. If the values returned are not what you think they should be then take it up with MS, not me. And the average difference in the "top" and "bottom" measurements of the text is just over 1mm - the maximum difference is 1.8mm. This is "very-very" small - why do you need such precision in the vertical position? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
SharkyEXE Posted July 14, 2021 Share Posted July 14, 2021 17 minutes ago, Melba23 said: why do you need such precision in the vertical position? Hello Sorry, I don't want to offend you If do no fixed by you - sorry, MS 100% do not fixed Thank You! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2021 Moderators Share Posted July 15, 2021 SharkeyEXE, I am not offended in the slightest - just trying to explain the limitations that Windows imposes on us! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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