Sign in to follow this  
Followers 0
mini

[SOLVED]Information on BUTTONS

7 posts in this topic

#1 ·  Posted (edited)

Heys all...

Well I've seen in some others GUI that wen we press the Yes button or the Start Button, the same button change to NO/Stop...

How can i make that on my buttons!?!? BTW and if i have a "TrayCreatItem" how can i make the same on that to!!

Thanks for all the replays.

Edited by mini

Share this post


Link to post
Share on other sites



Change the button text using

GUICtrlSetData

Change tray text using

TrayItemSetText

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Change the button text using

GUICtrlSetData

Change tray text using

TrayItemSetText

Hi again...

well i've been able to change the text to STOP when i press the Start Button...

But I'm missing to much code to make it back if the button is pressed again, can some one help me on it please.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 373, 305)


$Button_Start = GUICtrlCreateButton("Start", 75, 270, 50, 25)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



While 1
    $nMsg = GUIGetMsg()
    Switch GUIGetMsg() ; Check the valid events (no point in looking for Start as we are already running!)
        Case -3
            Exit
        Case $Button_Start
            _Check4Start()


    EndSwitch



WEnd

Func _Check4Start()
    guictrlsetdata($Button_Start,"Stop")

EndFunc   ;==>_Check4Start
Edited by mini

Share this post


Link to post
Share on other sites

Here's one way to handle 2 or more "texts" pretty easy:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 373, 305)

$Button_Start = GUICtrlCreateButton("Start", 75, 270, 50, 25)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg() ;Having two GUIGetMsg seemed unnecessary.
        Case -3
            Exit
        Case $Button_Start
            _Check4Start()
    EndSwitch
WEnd

Func _Check4Start()
    Switch GUICtrlRead($Button_Start)
        Case "Start"
            guictrlsetdata($Button_Start, "Stop")
        Case "Stop"
            GUICtrlSetData($Button_Start, "Start")
    EndSwitch
EndFunc   ;==>_Check4Start

Share this post


Link to post
Share on other sites

Track your run status with a global flag variable:

#include <GUIConstantsEx.au3>

Global $hForm1, $idLabel, $idButton, $f_Run = False

$hForm1 = GUICreate("Form1", 300, 300)
$idLabel = GUICtrlCreateLabel("We have not started...", 20, 20, 260, 20)
$idButton = GUICtrlCreateButton("Start", 100, 250, 100, 30)
GUISetState(@SW_SHOW)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idButton
            _Check4Start()
    EndSwitch
WEnd

Func _Check4Start()
    $f_Run = Not $f_Run
    If $f_Run Then
        GUICtrlSetData($idLabel, "We are running...")
        GUICtrlSetData($idButton, "Stop")
    Else
        GUICtrlSetData($idLabel, "We have stopped...")
        GUICtrlSetData($idButton, "Start")
    EndIf
EndFunc   ;==>_Check4Start


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks for your replays guys...

@ AdmiralAlkex

Your code is more simple, i think its better for my Gui, since I'm not a good coder. Still learning how does this all work.

@ PsaltyDS

I don't think i can menage to use your code on my Gui.

That was just a "test run" to see how i change the text of buttons, now i need to implement them on my MAIN code, and hope i can understand (if it doesn't work) how it works.

Thank you two very much for the code/help.

Regards.

Edited by mini

Share this post


Link to post
Share on other sites

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