Jump to content

Extended Message Box - New Version: 16 Feb 24


Melba23
 Share

Recommended Posts

  • Moderators

Zehir,

First question: Use my StringSize UDF (included in the ExtMsgBox download) to measure the size of the unbroken text and then use _ExtMsgBox_Set to increase the max size of the ExMsgBox. This will allow the long unbroken strings to display:

#include "ExtMsgBox.au3"

Global $aText[] = ["Short text", _
                   "Medium_text_Medium_text_Medium_text", _
                   "Long_text_Long_text_Long_text_Long_text_Long_text_Long_text_Long_text_Long_text", _
                   "Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text"]

For $i = 0 to 3
    ; Determine text width
    $aSize = _StringSize($aText[$i])

    ; Set max size of the ExtMsgBox
    _ExtMsgBoxSet(0, Default, Default, Default, Default, Default, Default, $aSize[2] + 40)
        ; Note use of 0 and not Default for the first parameter - read the function header to see why !!!!
        ; Add 40 to the text width to allow for the dialog borders, etc

    ; Display ExtMsgBox which will now expand to allow the text to display
    $iRet = _ExtMsgBox(0, 0, "Width: " & $aSize[2], $aText[$i])

Next

Second question: Not going to happen - getting the dialog sizing right is hard enough when all the buttons are the same size! Besides, I would argue that having masses of text on a button is not good practice - short and sweet should be the mantra here.

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

Melba23,

I have modified your example to show the error.

It happens when the unbroken string is wider than the screen or almost.

#pragma compile(Icon, C:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\AutoIt_Main_v11_256x256_RGB-A.ico)
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7

#include "ExtMsgBox.au3"

Global $aText[] = ["Short text", _
                   "Medium_text_Medium_text_Medium_text", _
                   "Long_text_Long_text_Long_text_Long_text_Long_text_Long_text_Long_text_Long_text", _
                   "Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text_Very_long_text"]


$aText[3] = $aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]&$aText[3]


For $i = 0 to 3
    ; Determine text width
    $aSize = _StringSize($aText[$i])

    ; Set max size of the ExtMsgBox
    _ExtMsgBoxSet(0, Default, Default, Default, Default, Default, Default, $aSize[2] + 40)
        ; Note use of 0 and not Default for the first parameter - read the function header to see why !!!!
        ; Add 40 to the text width to allow for the dialog borders, etc

    ; Display ExtMsgBox which will now expand to allow the text to display
    $iRet = _ExtMsgBox(0, 0, "Width: " & $aSize[2], $aText[$i])
    ConsoleWrite("@error = " & @error&@CRLF)

Next

 

Link to comment
Share on other sites

  • Moderators

Zehir,

Quote

It happens when the unbroken string is wider than the screen or almost

If you read the function header for _ExtMsgBox_Set you will see that the maximum value is limited to just under full screen width:

Quote

$iWidth_Abs     -> Absolute max width for EMB. Default/min = 370 pixels - max = @DesktopWidth - 20

and if you look at the return, @error and @extended values returned by the _ExtMsgBox_Set calls, you will see that the final (very, very long) text tells you the call failed with an error in the 8th parameter. I do not think I can make it any clearer what went wrong to the user than that - and once again I wonder why I bother to write the comprehensive headers and include all the errorchecking code in my UDFs as no-one ever seems to read them or inspect the informative return values.

Anyway, what kind of unbroken strings are you trying to display that are wider than the screen itself? Whatever they are, a fixed size dialog does not seem to be the correct control to use - I would suggest an edit control which will allow to you to scroll as required.

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

Melba23, 

I'm sorry if I missed something. I'm not talking about the possibility to expand the GUI beyond the screen width, but the possibility to display an unbroken string wider than the screen.

Is it possible?  Do you have a working example of this?

I want to use _ExtMsgBox() to make a user function, then I would like to use it while being able to forget details like the max width of an unbroken string.

Maybe before calling _ExtMagBox() I could call _StringSize() on every single word in the Text parameter, if the word width is too big then break it at 50% of its lenght, call _StringSize() again on the same word, then try to break it to 75% or 25% and so on.

Edited by Zehir
Link to comment
Share on other sites

  • Moderators

Zehir,

Quote

I'm sorry if I missed something

Yes, you CANNOT use this UDF to display an unbroken string wider than the screen. As I told you above, you need to use a scrollable control such as an edit box. But that is outside the scope of this particular UDF so I suggest you open a new thread if you want help - although I suggest you try to produce some code yourself first.

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

Zehir,

I see you edited your earlier post after I had replied.

Your suggestion of using using StringSize to check on string lengths and then breaking any that are too long is an excellent solution to your problem. But as I said above, please open a new thread when you need help.

But I am still somewhat bemused by the requirement to display huge unbroken strings - which now apparently can be arbitrarily broken at will. Very mysterious!

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

  • 3 months later...

Hey Melba,

I'm using the latest version (19 Nov 21) on AutoIt 3.3.16.0.  I added this to a script that doesn't have an AutoIt GUI involved and hit a small nuisance. I dug into it and found that it's because none of the chained #include <ExtMsgBox.au3> have any references to  $SS_LEFT, $SS_CENTER, $SS_RIGHT for use as the 2nd parameter ($iJust) of _ExtMsgBoxSet(). I prefer using constants for readability, and these are referenced as being allowed. Did you put that in there just to see if anyone reads the docs? 🤓

Possible solutions are these in my recommended order:

  1. Remove the mention of $SS_LEFT, $SS_CENTER, $SS_RIGHT from the  _ExtMsgBoxSet() function header in ExtMsgBox.au3 (I.e. Delete line 98), and from being used your ExtMsgBox_Example_1.au3 and ExtMsgBox_Example_3.au3.
  2. Add #include <StaticConstants.au3> to ExtMsgBox.au3. I'm currently adding this as an #include to my scripts beneath ExtMsgBox.au3 as you did in Examples 1 & 3.
  3. Add $SS_LEFT, $SS_CENTER, $SS_RIGHT as Global Const in ExtMsgBox.au3. It's messy using the same names that exist elsewhere though.

Not a big deal, but if you're looking to post an updated version any time soon this might help some others from hitting this bump. I got lucky with the first script that I used your UDF with because I had #include <GUIConstants.au3> in it, which includes StaticConstants.au3 so everything "just worked."

Thanks for this UDF!

Link to comment
Share on other sites

  • Moderators

Decibel,

Thanks for that report - I am amazed no-one has discovered that problem before now!

I have added a rider to the line which mentions those constants explaining that StaticConstants.au3 must be included if they are to be used.

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

  • 1 month later...

This is a great UDF that has helped me with my current project so much.  There is one feature I am looking for that I don't think is a part of the current version, but I want to make sure.

Is it possible to change the font size of the countdown timer(replacing the icon field) in msgboxes.  The default size is a bit too small and I can't seem to find a way to change it.

Link to comment
Share on other sites

  • Moderators

Bildozer,

There is nothing at the moment to increase the font size of the countdown timer - but be patient.....

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

Bildozer,

Here you go - setting the timeout value to a negative value doubles the size of the countdown font: ExtMsgBox_Mod.au3

Or you can try this one where you need to add 128 to the $iStyle parameter of _ExtMsgBoxSetExtMsgBox_ModSet.au3

Which do you prefer?

M23

Edited by Melba23

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

  • 3 weeks later...

I made some GUIs in my application and some of them use Opt("GUICoordMode", 2). But it seems when this is set, the buttons in _ExtMsgBox basically break as they appear off-menu.

The easiest way to replicate this issue is to simply open ExtMsgBox_Example_1.au3 and change this code:

Case $hButton1

; Set the centred value and font size, leave colours and font name unchanged, set default sizes and change default focus button character
;_ExtMsgBoxSet(2, $SS_CENTER, -1, -1, 9, -1, Default, Default, "#")

Opt("GUICoordMode", 2)

$sMsg = "This is centred on 'EMB Test' with the AutoIt icon, 4 buttons, centred text,a Taskbar button and TOPMOST not set" & @CRLF & @CRLF
$sMsg &= "The width is set to maximum by the requirement for 4 buttons and the text will wrap if required to fit in" & @CRLF & @CRLF
$sMsg &= "Button 4 is set as default and will action on 'Enter' or 'Space'" & @CRLF & @CRLF
$sMsg &= "It will not time out"
$iRetValue = _ExtMsgBox(@AutoItExe, "OK|Cancel", "Test 1", $sMsg, 0, $hTest_GUI) ; Note changed focus button character
ConsoleWrite("Test 1 returned: " & $iRetValue & @CRLF)

; Reset to default, including default focus button character
_ExtMsgBoxSet(Default)

By adding that Opt("GUICoordMode", 2), it breaks the demo as the buttons now appear offscreen. 

EDIT:

I solved this by adding Local $oldCoord = Opt("GUICoordMode", 1) to the beginning of _ExtMsgBox and Opt("GUICoordMode", $oldCoord) to the end. Is that the best approach?

Edited by lowbattery
Link to comment
Share on other sites

  • Moderators

lowbattery,

Quote

Is that the best approach?

Absolutely. In several of my UDFs you will find similar lines - in particular dealing with "GUIOnEventMode".  Interesting that this is the first such report that has been received about this particular Opt change - it would appear that not too many people use anything other then the default "GUICoordMode".

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

  • 2 months later...

Hi Melba,

I just changed the logo (from the 1st page zip file) to fit like Windows 11.

Old code:

; Get required display icon data
    If StringIsDigit($vIcon) Then
        Switch $vIcon
            Case 0
                $iIcon_Reduction = 0
            Case 8
                $sDLL = "imageres.dll"
                $iIcon_Style = 78
            Case 16 ; Stop
                $iIcon_Style = -4
            Case 32 ; Query
                $iIcon_Style = -3
            Case 48 ; Exclam
                $iIcon_Style = -2
            Case 64 ; Info
                $iIcon_Style = -5
            Case 128 ; Countdown
                If $iTimeOut > 0 Then
                    $fCountdown = True
                EndIf
            Case Else
                Return SetError(1, 0, -1)
        EndSwitch
    Else
        If StringInStr($vIcon, "|") Then
            $iIcon_Style = StringRegExpReplace($vIcon, "(.*)\|", "")
            $vIcon = StringRegExpReplace($vIcon, "\|.*$", "")
        EndIf
        ; Parse data
        Switch StringLower(StringRight($vIcon, 3))
            Case "exe", "ico"
                $sDLL = $vIcon
            Case "bmp", "jpg", "gif", "png"
                $sImg = $vIcon
        EndSwitch
    EndIf

New code:

; Get required display icon data
    If StringIsDigit($vIcon) Then
        Switch $vIcon
            Case 0
                $iIcon_Reduction = 0
            Case 8
                $sDLL = "imageres.dll"
                $iIcon_Style = 78
            Case 16 ; Stop
                $sDLL = "imageres.dll"
                $iIcon_Style = 98
            Case 32 ; Query
                $sDLL = "imageres.dll"
                $iIcon_Style = 99
            Case 48 ; Exclam
                $sDLL = "imageres.dll"
                $iIcon_Style = 84
            Case 64 ; Info
                $sDLL = "imageres.dll"
                $iIcon_Style = 81
            Case 128 ; Countdown
                If $iTimeOut > 0 Then
                    $fCountdown = True
                EndIf
            Case Else
                Return SetError(1, 0, -1)
        EndSwitch
    Else
        If StringInStr($vIcon, "|") Then
            $iIcon_Style = StringRegExpReplace($vIcon, "(.*)\|", "")
            $vIcon = StringRegExpReplace($vIcon, "\|.*$", "")
        EndIf
        ; Parse data
        Switch StringLower(StringRight($vIcon, 3))
            Case "exe", "ico"
                $sDLL = $vIcon
            Case "bmp", "jpg", "gif", "png"
                $sImg = $vIcon
        EndSwitch
    EndIf

 

Best regards !

C.

Link to comment
Share on other sites

  • Melba23 changed the title to Extended Message Box - New Version: 16 Feb 24
  • Moderators

[NEW VERSION] 16 Feb 24

Changed: Some additional functionality added to the "TimeOut" parameter of _ExtMsgBox:

    - A positive integer sets the EMB timeout as before.

   - A negative integer will double the size of the countdown timer if it is used.

   - A colon-delimited string (eg: "10:5") will set the normal EMB timeout (first integer) and will also initially disable the EMB buttons for the required period (second integer).

New UDF and examples in the first post.

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

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