Jump to content
Sign in to follow this  
sbrady

how to left align button text in GUI

Recommended Posts

sbrady

how do I make the text in all these buttons be left aligned. thanks

; GUI create

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

Example()

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

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("1. Desktop Prep", 10, 30, 110)
    $Button_2 = GUICtrlCreateButton("2. Open AM", -110, 10, 110)
    $Button_3 = GUICtrlCreateButton("3. NDP  AM",  -110, 10, 110)
    $Button_4 = GUICtrlCreateButton("4. BUMP AM",  -110, 10, 110)
$Button_5 = GUICtrlCreateButton("5. 7CIOPEN AM",  -110, 10, 110)
$Button_6 = GUICtrlCreateButton("6. 7CINDP AM",  -110, 10, 110)
$Button_7 = GUICtrlCreateButton("7. 7CINDPC AM",  -110, 10, 110)
$Button_8 = GUICtrlCreateButton("8. Email-DMG", -110, 10, 110)

    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
                MsgBox(0, 'Desktop Prep Begins', 'Desktop Prep Begins') ; Will Run/Open Notepad
            Case $msg = $Button_2
                MsgBox(0, 'Open AM', 'Open AM was pressed') ; Will demonstrate Button 2 being pressed
Case $msg = $Button_3
                MsgBox(0, 'NDP AM', 'NDP AM was pressed') ; Will demonstrate Button 2 being pressed
Case $msg = $Button_4
                MsgBox(0, 'BUMP AM', 'Bump AM was pressed') ; Will demonstrate Button 2 being pressed
Case $msg = $Button_5
                MsgBox(0, '7CI AM', '7CIOPEN AM was pressed') ; Will demonstrate Button 2 being pressed
Case $msg = $Button_6
  MsgBox(0, '7CI AM', '7CINDP AM was pressed') ; Will demonstrate Button 2 being pressed
Case $msg = $Button_7
                MsgBox(0, '7CI AM', '7CINDPC AM was pressed') ; Will demonstrate Button 2 being pressed
Case $msg = $Button_8
                MsgBox(0, 'E-mail & DMG', 'E-mail/DMG was pressed') ; Will demonstrate Button 2 being pressed
        EndSelect
    WEnd
EndFunc   ;==>Example
Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

sbrady,

Use the $BS_LEFT style: :)

$Button_1 = GUICtrlCreateButton("1. Desktop Prep", 10, 30, 110, 30, $BS_LEFT) ; Note you need to define the height

And when you post code, please use Code tags - put [autoit] before and [/autoit] after your posted code. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
sbrady

it works, thanks

Share this post


Link to post
Share on other sites
Exit

$Button_1 = GUICtrlCreateButton("1. Desktop Prep", 10, 30, 110, 30, $BS_LEFT) ; Note you need to define the height

Note you need to define the height.

or use default -1 ;)

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
_Example()
Func _Example()
Opt("GUICoordMode", 2)
GUICreate("My GUI Buttons")
$Button_1 = GUICtrlCreateButton("1. Desktop Prep", 10, 30, 110, -1, $BS_LEFT) ;
$Button_2 = GUICtrlCreateButton("2. Open AM", -1, 10, 110, -1, $BS_LEFT)
$Button_3 = GUICtrlCreateButton("3. NDP AM", -1, 10, 100, -1, $BS_LEFT)
$Button_4 = GUICtrlCreateButton("4. BUMP AM", -1, 10, 100, -1, $BS_LEFT)
$Button_5 = GUICtrlCreateButton("5. 7CIOPEN AM", -1, 10, 100, -1, $BS_LEFT)
$Button_Exit = GUICtrlCreateButton(" Exit", -1, 10, 100, -1, $BS_LEFT)
$Button_6 = GUICtrlCreateButton("6. 7CINDP AM", -1, 10, 100, -1, $BS_LEFT)
$Button_7 = GUICtrlCreateButton("7. 7CINDPC AM", -1, 10, 100, -1, $BS_LEFT)
$Button_8 = GUICtrlCreateButton("8. Email-DMG", -1, 10, 100, -1, $BS_LEFT)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE, $Button_Exit
    Exit MsgBox(8192 + 262144, '', 'Bye Bye', 1)
Case $Button_1 To $Button_8
    $s = GUICtrlRead($msg)
    MsgBox(8192 + 262144, '', $s, 1)
EndSwitch
WEnd
EndFunc ;==>_Example

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
Melba23

Exit,

You are quite correct. I should have stated: "You need to make sure you add a height parameter" as I was only making sure that the style parameter was in the correct place. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×