Sign in to follow this  
Followers 0
althurm

line feed in a buttons text

5 posts in this topic

Hello all,

 Currently I have a script that will display a big button as part of a GUI. After creating the Gui I create the button using GUICtrlCreateButton(). The first parameter which is the text, I have a lot of text in which I have several carriage return/line feeds (see below). But when I do this in a button text it does not do a new line (the whole string is one line). Does anyone know what I'm doing wrong?

$Button = GUICtrlCreateButton("-- First Line of text" & @CRLF & @CRLF & "-- 2nd line of txt" & @CRLF & @CRLF & "-- 3rd line", 1, 1, 798, 600, 0x0400) 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

http://www.autoitscript.com/autoit3/docs/appendix/GUIStyles.htm#Button

$BS_MULTILINE

use bitor to combine the diff sytles

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Run Notepad" & @CRLF & "Run Notepad" & @CRLF & "Run Notepad", 10, 30, 100,50, bitor($BS_MULTILINE,0x0400))
    $Button_2 = GUICtrlCreateButton("Button Test", 0, -1)

    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                Run('notepad.exe') ; Will Run/Open Notepad
            Case $msg = $Button_2
                MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
        EndSelect
    WEnd
EndFunc   ;==>Example
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

I'm surprised that style exists, as buttons should be used for an action.

Microsoft Styles


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

 

http://www.autoitscript.com/autoit3/docs/appendix/GUIStyles.htm#Button

$BS_MULTILINE

use bitor to combine the diff sytles

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Run Notepad" & @CRLF & "Run Notepad" & @CRLF & "Run Notepad", 10, 30, 100,50, bitor($BS_MULTILINE,0x0400))
    $Button_2 = GUICtrlCreateButton("Button Test", 0, -1)

    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                Run('notepad.exe') ; Will Run/Open Notepad
            Case $msg = $Button_2
                MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
        EndSelect
    WEnd
EndFunc   ;==>Example

That works, thanks. I noticed when using Bitor applying extra styles doesn't work. I tried BitOR($BS_MULTILINE, $BS_BOTTOM) but everything is still at the top. I also noticed there does not seem to be a left justify. Any idea how to do that?

$Button = GUICtrlCreateButton(@CRLF & "-- First Line of txt" & @CRLF & @CRLF & "-- 2nd line of txt" & @CRLF & @CRLF & "-- 3rd line", 1, 1, 798, 600, BitOR($BS_MULTILINE, $BS_BOTTOM) )

Share this post


Link to post
Share on other sites

$bs_bottom works...you probably just don't see it...add a lot of height:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Run Notepad" & @CRLF & "Run Notepad" & @CRLF & "Run Notepad", 10, 30, 100,100, bitor($BS_MULTILINE,$BS_BOTTOM))
    $Button_2 = GUICtrlCreateButton("Button Test", 0, -1)

    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                Run('notepad.exe') ; Will Run/Open Notepad
            Case $msg = $Button_2
                MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
        EndSelect
    WEnd
EndFunc   ;==>Example

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
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
Sign in to follow this  
Followers 0