Jump to content

Dynamic SplashTextOn


Go to solution Solved by Melba23,

Recommended Posts

  • Moderators
  • Solution

mr-es335,

Use my StringSize UDF (link in my sig) to get the width and height of the text you wish to display.

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by mr-es335
Link to comment
Share on other sites

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
; -----------------------------------------------

_StringSizeSplashTextOn.png.07afa32fe1109297afdeaf4800169959.png

_StringSizeSplashTextOn2.png.9653e0143f1b99c1771f3cfa6af9bd34.png

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

Splashhadnomargins.png.9076add9b73edd4c1861dc6f05692701.png

 

Edited by pixelsearch
Explanation of the +22
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...