mr-es335 Posted September 27 Share Posted September 27 Good day, I deploy many SplashTextOn commands in my scripts and it would be nice to have the ability to dynamically adjust for the width [...and the height as well, if at all possible...]. Any thoughts, suggestions? Thanks in advance...appreciated! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted September 27 Moderators Solution Share Posted September 27 mr-es335, Use my StringSize UDF (link in my sig) to get the width and height of the text you wish to display. M23 mr-es335 1 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...
mr-es335 Posted September 27 Author Share Posted September 27 (edited) Melba23, Thanks for the "heads-up"...appreciated! A question, "Is the text in SplashTextOn always "centred"? Edited September 27 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 27 Moderators Share Posted September 27 mr-es335, Have you read the Help file entry for SplashTextOn? If not, I suggest you do as you will find the answer to your question. 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...
mr-es335 Posted September 27 Author Share Posted September 27 Melba, Great! For whatever reason, I though that this setting might be a StringSize setting. Thanks for the clarification...appreciated! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
mr-es335 Posted September 28 Author Share Posted September 28 (edited) Hello, How do you actually place the StringSize text inside SplashTextOn? #include <AutoItConstants.au3> #include "StringSize.au3" ; ----------------------------------------------- _MessageText() ; ----------------------------------------------- Func _MessageText() $sText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." $sMessage = _StringSize($sText, Default, Default, Default) ; ----------------------------------------------- SplashTextOn("Title", $sMessage, 100, 100, -1, -1, $DLG_TEXTLEFT) Sleep(2000) SplashOff() EndFunc ;==>_MessageText ; ----------------------------------------------- Edited September 28 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
pixelsearch Posted September 28 Share Posted September 28 (edited) Melba23 will certainly explain better than I do. Meanwhile, @mr-es335 what did you expect with this statement : $sMessage = _StringSize(...) in his function, M23's explanation of the Return value is : Return value : Success - Returns 4-element array : $array[0] = ... $array[1] = ... $array[2] = ... $array[3] = ... But you keep on ignoring the Return value of functions and play with them as you like, same for @error. How will you improve your knowledge of AutoIt if you don't constantly focus on Return values and @error ? Here is a script I just wrote which allows _StringSize to be used with SplashTextOn. The important part is that you need to choose the same Font parameters (name, size and weight) in _StringSize and SplashTextOn. I hope it will work for you the same way it worked for me, fingers crossed ! @Melba23 When the instruction SplashTextOn is encountered, I had to add 22 pixels to $aArray[2] and $aArray[3] as the rectangle size returned by _StringSize has to become the size of the Static Label Control found in the Splash window. If we don't enlarge the Static control then SplashTextOn won't display the text correctly. Yashied's control viewer shows that by adding 22, then the Label Control got exactly the same width & height than $aArray[2] & $aArray[3] . More explanations in the Edit part at the end of this post. Tested with 2 different font names, 2 font size, 2 font width, 2 $iWidth (300 & 900), with a Splash window getting a title or not. Please advise if you think something seems incorrect. Thanks ! #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include "StringSize.au3" ; Melba23's UDF Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration ; ----------------------------------------------- _MessageText() ; ----------------------------------------------- Func _MessageText() Local $sText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." Local $iFontSize = 12, $iFontWeight = 400, $sFontName = "Tahoma", $iWidth = 900 ; <======== change 4 params. only here Local $aArray = _StringSize($sText, $iFontSize, $iFontWeight, 0, $sFontName, $iWidth) ; 4th param. Font attribute = 0 inexistant in SplashTextOn If @error Then Exit MsgBox($MB_TOPMOST, "_StringSize error", "@error = " & @error & " @extended = " & @extended) ; ----------------------------------------------- ConsoleWrite($aArray[0] & @crlf) ; "String reformatted with additional @CRLF when 6th param. $iWidth set" (Melba23's comment in function) ConsoleWrite($aArray[1] & " " & $aArray[2] & " " & $aArray[3] & @crlf) ; "Height of single line, Width of rectangle, Height of rectangle" SplashTextOn("Title", $aArray[0], $aArray[2] + 22, $aArray[3] + 22, -1, -1, _ $DLG_TEXTLEFT + $DLG_MOVEABLE, $sFontName, $iFontSize, $iFontWeight) Sleep(5000) SplashOff() EndFunc ;==>_MessageText ; ----------------------------------------------- Edit: explanation of the +22 * Back in 2005 (AutoIt version 3.1.0) SplashTextOn had its static label control taking all the place of the client area (see pic below) so there were no margins for the text displayed in the Splash window. * In 2024 (AutoIt version 3.3.16.1) and since many years, SplashTextOn displays the text with a margin of 11 (applied to left, top, right, bottom) as shown in Yashied's control viewer, that's why we need to add 22 (i.e. 11*2) to the StringSize rectangle coords (width & height), forcing the label control in SplashTextOn to have exactly the same coords as StringSize Edited September 29 by pixelsearch Explanation of the +22 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