Jump to content

Line break in GuiCtrlCreateInput


Recommended Posts

Trying to enter a line break every 60 chars to create a "centered" look on a long message in Input control.  This was the only way I could find after looking around for awhile, if anyone has a better method let me know!

 

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
Opt("GUIOnEventMode", 1)

Global $Count = 0, $Message, $MessageDisplay
Dim $Trim[4000]
GUICreate("Dummy", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Message = "This is a long text that I would like to split up at 60 chars and then reinput into the Input control using a LB at 60 chars!"
$Len = StringLen($Message)
$Trim[$Count] = StringTrimRight($Message, $Len - 60)
$Message = StringTrimLeft($Message, 60)
For $i = 1 To 100
    $Len = StringLen($Message)
    If $Len > 60 Then
        $Count += 1
        $Trim[$Count] = StringTrimLeft($Message, 60)
        $Message = StringTrimLeft($Message, 60)
    Else
        $Count += 1
        $Trim[$Count] = $Message
        ExitLoop
    EndIf
Next
For $i = 0 To $Count
    $MessageDisplay = $MessageDisplay & $Trim[$i] & @CRLF ; This is where I want to add in line breaks and recreate the entire message.
Next

$Display = GUICtrlCreateInput($MessageDisplay, 10, 10, 180, 180, BitOR($ES_CENTER, $ES_READONLY, $ES_MULTILINE))

GUISetState()

Func _Exit()
    Exit
EndFunc   ;==>_Exit

While 1
    Sleep(10)
WEnd

 

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

You'll have to use an edit control instead of an input if you want to have multiple lines.

You could also check this out. Something I did a while ago, formats a very long string to fit a label based on the width of the label. Easily work for an edit too.

 

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