caseelse Posted September 18, 2010 Share Posted September 18, 2010 Hello everybody! I'm trying to create a label which displays strings of up to 64 characters (alphanumeric and special chars). However, the label is 32 chars wide and 2 chars high. So I would like strings with more than 32 chars to wrap to two lines without having to insert spaces anywhere in the string. This is what it looks like at the moment #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ... GUICtrlCreateLabel("1234567890123456789012345678901234567890123456789012345678901234", 20, 145, 195, 30, $SS_CENTER+$SS_SUNKEN) (The numeric string is only an example for debugging purposes.) Can anybody point me in the right direction, please? Thanks CE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 18, 2010 Moderators Share Posted September 18, 2010 caseelse,Welcome the the AutoIt forum. Just test the length of the string before displaying it: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $hGUI = GUICreate("Test", 500, 500) $sData = "1234567890123456789012345678901234567890123456789012345678901234" If StringLen($sData) > 32 Then $sData = StringMid($sData, 1, 32) & @CRLF & StringMid($sData, 33) GUICtrlCreateLabel($sData, 20, 145, 195, 30, BitOR($SS_CENTER, $SS_SUNKEN)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndNote the use of BitOR to set multiple styles. You can find out why you should do it this way in the Setting Styles tutorial in the Wiki. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
caseelse Posted September 18, 2010 Author Share Posted September 18, 2010 Hi M23,Thanks for your warm welcome and your great help.I had been hoping that there was some style or something so that I could avoid modifying the string. However, I think I'm just going to externalize your split string function so that I can keep the original string intact and continue using it in the program.Note the use of BitOR to set multiple styles. You can find out why you should do it this way in the Setting Styles tutorial in the Wiki. That is a great tip. I have to admit that I'm just a hobby programmer and so far have only been creating very simple apps in VB6 . This little program is part of my effort to migrate them to AutoIt so that I won't need the stupid VB runtimes anymore.Anyway, you certainly helped me a lot.Thanks againcheersCE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 18, 2010 Moderators Share Posted September 18, 2010 caseelse,I'm just a hobby programmerSo am I - fun, isn't it! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ajag Posted September 18, 2010 Share Posted September 18, 2010 I have to admit that I'm just a hobby programmer and so far have only been creating very simple apps in VB6 I created some professional applications using VB4 and VB6. Don't think VB is for hobbyists only (like many others do)! [...] to migrate them to AutoIt so that I won't need the stupid VB runtimes anymore. This is one reason for me too to use AutoIt (or Borland C++ Builder) . A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
caseelse Posted September 19, 2010 Author Share Posted September 19, 2010 Don't think VB is for hobbyists only (like many others do)! Yepp, I know what great things other people can do with VB6 - just not me I tried learning C/C++ at one point and managed to get the basic concepts. However, the language soon became too abstract for me. Basically, I'm only using programming to automate repeating tasks and speed up things on PC and Mac. So whatever I'm coding, it's always solution-oriented and the breaks in between are usually so long that at the beginning I always have to look up even simple things again because I don't quite remember the exact syntax. So, "hobby programmer" might not be the correct term, more like "necessity programmer" Anyway, it just feels great when it works in the end and the thing does exactly what I wanted it to. (With the results I can't usually impress anybody except my wife who doesn't care too much about computers ) 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