Jump to content

[SOLVED]Information on BUTTONS


mini
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...