Jump to content

ExtMsgBox wrong width with fixed font


Recommended Posts

When I set ExtMsgBox to use fixed font, the width is calculated incorrectly, so text wraps.

my code:

#include <_ExtMsgBox.au3>
#include <Array.au3>

    _ExtMsgBoxSet(0, 0, -1, -1, 10, "courier new") ; Set _ExtMsgBox formatting

ShowAbout()

Func ShowAbout()
    Local $ar[1] = [0]

    _ArrayAdd($ar, "Program to bla bla bla.")
    _ArrayAdd($ar, "")
    _ArrayAdd($ar, "usage: " & "[-switch>] [<datafile>.csv]")
    _ArrayAdd($ar, "")
    _ArrayAdd($ar, "<-switch>:")
    _ArrayAdd($ar, "-h ....... Display this help information")
    _ArrayAdd($ar, "-nb ...... Do not create backup files.")
    _ArrayAdd($ar, "-regdel... Delete program relative registry items before")
    _ArrayAdd($ar, "           running (debug mode only)")
    _ArrayAdd($ar, "-ro ...... Do not modify the input file.")
    _ArrayAdd($ar, "-tail .... Launch 'Tail' to tail the debug output file")
    _ArrayAdd($ar, "")
    _ArrayAdd($ar, "Copyright 2011-2016, Andy Scharmer")
    _ExtMsgBox(8, "OK", "About", _ArrayToString($ar, @CRLF, 1))
    Return
EndFunc   ;==>ShowAbout

 

Link to comment
Share on other sites

  • Moderators

AndyS01,

As explained in the UDF function headers, the normal max width of the ExtMsgBox is 370 pixels - as you have not altered this in the _ExtMsgBoxSet call, that is the width you get and so as the text is too wide to fit, it wraps. You need to increase the max width of the ExtMsgBox to fit the text. I did it this way:

#include <ExtMsgBox.au3>

ShowAbout()

Func ShowAbout()

    ; Create the string in a more logical manner
    Local $sString
    $sString &= "Program to bla bla bla." & @CRLF
    $sString &= @CRLF
    $sString &= "usage: " & "[-switch>] [<datafile>.csv]"
    $sString &= @CRLF
    $sString &= "<-switch>:" & @CRLF
    $sString &= "-h ....... Display this help information" & @CRLF
    $sString &= "-nb ...... Do not create backup files." & @CRLF
    $sString &= "-regdel... Delete program relative registry items before" & @CRLF
    $sString &= "           running (debug mode only)" & @CRLF
    $sString &= "-ro ...... Do not modify the input file." & @CRLF
    $sString &= "-tail .... Launch 'Tail' to tail the debug output file" & @CRLF
    $sString &= @CRLF
    $sString &= "Copyright 2011-2016, Andy Scharmer" & @CRLF

    ; Size the string
    $aRet = _StringSize($sString, 10, Default, Default, "Courier New")

    ; Now set the ExtMsgBox to a width which will accommodate the widest line
    _ExtMsgBoxSet(0, 0, -1, -1, 10, "Courier New", $aRet[2] + 70) ; 70 = 50 for the icon + 2 borders of 10

    ; And it fits!!!
    _ExtMsgBox(8, "OK", "About", $sString)

EndFunc   ;==>ShowAbout

In fact you can increase the ExtMsgBox width to any value larger than the string width + 70 and the UDF will adjust the width to fit. All clear?

M23

Edited by Melba23
Additional info

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

×
×
  • Create New...