ReconX Posted May 9, 2014 Share Posted May 9, 2014 (edited) I want to be able to add a second line of text on each button, or even a string of text as a second line. This is what I have so far. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <array.au3> ; An array to hold the label ControlIDs Global $aLabel[6] ; A variable to show the last label which changed colour Global $iLastLabel = 0 Global $aText[6] = ["Malwarebytes Removal ToolHi", "Second label", "Third label", "Fourth label", "Fifth label", "Sixth label"] $hGUI = GUICreate("Test", 500, 600) For $i = 0 To 5 $aLabel[$i] = GUICtrlCreateLabel($aText[$i], 0, 0 + (50 * $i), 450, 45, BitOr($SS_CenterImage, $SS_Center)) GUICtrlSetBkColor($aLabel[$i], $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 13, 800) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Get cursor info $aCInfo = GUIGetCursorInfo($hGUI) ; loop through the label array to see which one is under the cursor For $i = 0 To 5 ; If we are over a new label If $aCInfo[4] = $aLabel[$i] And $iLastLabel <> $i Then ; Recolour previos label GUICtrlSetBkColor($aLabel[$iLastLabel], $GUI_BKCOLOR_TRANSPARENT) ; colour current label GUICtrlSetBkColor($aLabel[$i], 0xFF0000) ; Store this label $iLastLabel = $i ; No point in looking further ExitLoop EndIf Next WEnd Help would be appreciated. Edited May 9, 2014 by ReconX Link to comment Share on other sites More sharing options...
abberration Posted May 9, 2014 Share Posted May 9, 2014 A regular label allows you to have multiple lines, so I looked up $SS_CenterImage in the help guide and found this in the description: It can be used with static control having only one line of text. I guess you cannot have two lines of text in with this option. I ran the code modifying the line without $SS_CenterImage and was able to get two lines of text. Perhaps changing these two lines of code... Global $aText[6] = ["Malwarebytes Removal ToolHi", 'Second label' & @CRLF & '2nd line', "Third label" & @CRLF & "2nd line again", "Fourth label", "Fifth label", "Sixth label"] ... <code inbetween> ... $aLabel[$i] = GUICtrlCreateLabel($aText[$i], 0, 0 + (50 * $i), 450, 45, $SS_Center) Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
ReconX Posted May 10, 2014 Author Share Posted May 10, 2014 Thanks for that tip. I wouldn't have thought that would have been the case. Is there a way to add padding to the button at least? Instead of the $SS_CenterImage option? Link to comment Share on other sites More sharing options...
JohnOne Posted May 10, 2014 Share Posted May 10, 2014 Well you can on a button but not on a label (static control) like you have. If your text is fixed, then one suggestion would be to use actual images with that text on. I'm sure there would be a way to dynamically add text to an image also but it'd be rather complicated and not in the scope of this question. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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