Sign in to follow this  
Followers 0
copyleft

GUI & Button Help

3 posts in this topic

I need to center the text "Please choose a LAN Map" in LINE 9 as well as center the three buttons and give them additional spacing between each other. I've played with the series of four numbers after the GUICtrlCreateButton lable. But the numbers don't seem to adjust the spacing of the buttons

#include <GUIConstantsEx.au3>
  #include <IE.au3>
Opt("GUIOnEventMode", 1)
Global $ExitID
_Main()
Func _Main()
Local $SGAID, $TAIPETID
GUICreate("LAN Map", 275, 125)
GUICtrlCreateLabel("Please choose a LAN Map.", 10, 10)
$SGAID = GUICtrlCreateButton("SGA", 10, 50, 70, 20)
GUICtrlSetOnEvent($SGAID, "OnSGA")
$TAIPETID = GUICtrlCreateButton("TAIPET", 80, 50, 70, 20)
GUICtrlSetOnEvent($TAIPETID, "TAIPET")
$ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)
GUICtrlSetOnEvent($ExitID, "OnExit")
GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit")
GUISetState()
While 1
  Sleep(500)
WEnd
EndFunc

Same thing here, why is dialog box so large? The numbers after GUICtrlCreateRadio only adjust the spacing between the radio buttons not the size of the dialog window itself. Also, is there an easy way to dress up these dialog boxes? I'm lost with these GUI scripts.

#include <GUIConstantsEx.au3>
Example()
Func Example()
    Local $radio1, $radio2, $radio3, $radio4, $msg
    GUICreate("Choose Network Range") ; will create a dialog box that when displayed is centered
    $radio1 = GUICtrlCreateRadio("10 Taipet", 10, 10, 100, 20)
    $radio2 = GUICtrlCreateRadio("10 SMG", 10, 40, 100, 20)
$radio3 = GUICtrlCreateRadio("192 Generic", 10, 70, 100, 20)
$radio4 = GUICtrlCreateRadio("Exit", 10, 100, 100, 20)
    GUICtrlSetState($radio4, $GUI_CHECKED)
    GUISetState() ; will display an  dialog box with 1 checkbox

Share this post


Link to post
Share on other sites



copyleft,

I've played with the series of four numbers after the GUICtrlCreateButton lable. But the numbers don't seem to adjust the spacing of the buttons

And what does the Help file tell you about those "numbers"? They set the position and size of the buttons, so changing them will change the position and size of the buttons. Use some basic maths and you can easily position the buttons nicely. Or you can use the Koda app to design your GUI directly - look under the <Tools> menu in SciTE.

The same is true for your "Please choose" label. Either position the label in the appropriiate place using the left and top parameters - or you can make the label wide enough to fit the whole GUI and then use the $SS_CENTER style to let Windows sort it out.

Here is an example:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Opt("GUIOnEventMode", 1)

_Main()

Func _Main()
    Local $SGAID, $TAIPETID
    GUICreate("LAN Map", 275, 125)

    ; Make the label fill the GUI
    GUICtrlCreateLabel("Please choose a LAN Map.", 0, 10, 275, 20, $SS_CENTER) ; and let Windows centre the text

    ; We have 3 buttons to fit in 275 pixels.
    ; Allowing margins and spaces of 10 pixels gives us (275 - (10 * 4)) / 3 as a width = 78

    ; This button starts at 10
    $SGAID = GUICtrlCreateButton("SGA", 10, 50, 78, 20)
    GUICtrlSetOnEvent($SGAID, "fred")
    ; This one at 10 + 78 + 10 rounded to 100
    $TAIPETID = GUICtrlCreateButton("TAIPET", 100, 50, 78, 20)
    GUICtrlSetOnEvent($TAIPETID, "fred")
    ; And this one at 10, + 78 + 10 + 78 + 10 rounded to 190
    $ExitID = GUICtrlCreateButton("Exit", 190, 50, 78, 20)
    GUICtrlSetOnEvent($ExitID, "fred")
    GUISetOnEvent($GUI_EVENT_CLOSE, "fred")
    GUISetState()
    While 1
        Sleep(500)
    WEnd
EndFunc   ;==>_Main

Func fred()
    Exit
EndFunc

The dialog in your second example is so large because you have not defined its size. Autoit cannot read your mind - you need to tell it what size you want things:

#include <GUIConstantsEx.au3>
Example()
Func Example()
    Local $radio1, $radio2, $radio3, $radio4, $msg
    GUICreate("Choose Network Range", 250, 150) ; Define the size and that is what you get
    $radio1 = GUICtrlCreateRadio("10 Taipet", 10, 10, 100, 20)
    $radio2 = GUICtrlCreateRadio("10 SMG", 10, 40, 100, 20)
    $radio3 = GUICtrlCreateRadio("192 Generic", 10, 70, 100, 20)
    $radio4 = GUICtrlCreateRadio("Exit", 10, 100, 100, 20)
    GUICtrlSetState($radio4, $GUI_CHECKED)
    GUISetState() 

    While 1

        If GUIGetMsg() = -3 Then Exit

    WEnd
EndFunc   ;==>Example

All clear? Please ask if you have any questions. :oops:

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

#3 ·  Posted (edited)

Thanks for the beat down, as well as the explanation. Pretty clear I read the help file. It's just not very clear on this issue. Your explanations were much better, although AutoIt script checker complains about the use of $SS_CENTER, in your example when I add the button function run commands.

Edited by copyleft

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