althurm Posted June 20, 2013 Share Posted June 20, 2013 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) Link to comment Share on other sites More sharing options...
jdelaney Posted June 20, 2013 Share Posted June 20, 2013 (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 June 20, 2013 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. Link to comment Share on other sites More sharing options...
guinness Posted June 20, 2013 Share Posted June 20, 2013 I'm surprised that style exists, as buttons should be used for an action.Microsoft Styles UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
althurm Posted June 20, 2013 Author Share Posted June 20, 2013 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) ) Link to comment Share on other sites More sharing options...
jdelaney Posted June 20, 2013 Share Posted June 20, 2013 $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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now