Sign in to follow this  
Followers 0
SorryButImaNewbie

GUI Button doesn't show

5 posts in this topic

Hello and sorry!

I'm sorry because I know that there is a separet GUI help forum, but the General Help seems to be much more active. I started to learn GUIs today (I finished most of my Functions for a program, and I thought its time I start to develop the UI). I'm trying to place my buttons and even that seems to be a bit hard, I used to create UIs with some Graphic Interface (in C#), so I'm not good at building it from code. For this reason I started a simple GUI for some basic experience with the thing and I have a few questions already.

In default GUICtrlCreateButton should size the button width to the Text, yet this doesn't seems to be the case.

Also one of my button doesn't appear and I don't know why? (code below)

I would welcome any best practice or guides you like or was helpful when you was a beginner like me

(I have found https://www.autoitscript.com/forum/best-content/ , is anyone has experience with it? It looks good for me, but is it? I have to ask for permission before I download so i would like to hear its good before asking for permission)

Thank you for your help!

PS.: (In my posts in the forums I dont seems to be able to write anything after autoit code, more accuretly I can write but it doesnt display it)

The button that doesn't show is the $buttontest

MainGUI()
Func MainGUI()
    Local $Button1, $Button2, $msg, $buttontest
    GUICreate("Maga a csoda")

    Opt("GUICoordMode", 2)
    $Button1 = GUICtrlCreateButton("Egy gomb", 10, 30, 100)
    $Button2 = GUICtrlCreateButton("Másik gomb", 0, -1)
    $ButtonExit = GUICtrlCreateButton("Kilépés", 90,300)
    $buttontest = GUICtrlCreateButton("teszt",10,30,100)

    GUISetState(@SW_SHOW)
    GUICtrlSetState($Button2, $GUI_DISABLE)
    GUICtrlSetState($buttontest, $GUI_SHOW)
    Local $random = Random(1,10)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button1
                GUICtrlSetState($Button1, $GUI_DISABLE)
                GUICtrlSetState($Button2, $GUI_ENABLE)
                If $random < 5  Then
                    MsgBox(0, 'Button 1', 'Szép munka!')
                    Local $random = Random(1, 10)
                Else
                    MsgBox(0, 'Button 1', 'Megy ez, mint a kis autó!')
                    Local $random = Random(1, 10)
                EndIf
            Case $msg = $Button2
                GUICtrlSetState($Button1, $GUI_ENABLE)
                GUICtrlSetState($Button2, $GUI_DISABLE)
                If $random < 5  Then
                    MsgBox(0, 'Button 2', 'Így tovább!')
                    Local $random = Random(1, 10)
                Else
                    MsgBox(0, 'Button 2', 'Kell még gomb!')
                    Local $random = Random(1, 10)
                EndIf
            Case $msg = $ButtonExit
                ;ExitLoop
                Exit
            Case $msg = $buttontest
                MsgBox(0, 'Teszt', 'Megjelentem?')
        EndSelect
    WEnd
EndFunc   ;==>MainGUI

Share this post


Link to post
Share on other sites



Sorry

includes (and with this, this is the entire code)

#include <MsgBoxConstants.au3>
#include <GuiStatusBar.au3>
#include <GuiEdit.au3>
#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Opt("GUICoordMode", 2) places the controls relative to the last control.

$ButtonExit is right at the bottom, so your next button is off the gui.

Change to this to see what I mean...

$buttontest = GUICtrlCreateButton("teszt",-100,0,100)

Perhaps you might want to try >Form Designer, or >ISN AutoIt Studio.

You can find those in Example Scripts section.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yup, it works, I knew Opt("GUICoordMode", 2) was something i should have skipped, and try to use my own brain.

Anyway Thank you John you are the one ;)

I will use GUIStartGroups instead, and look in to these Designers, thanks

Edited by SorryButImaNewbie

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