Jump to content

change button name and function


Recommended Posts

not sure if this is possible,

say there is a gui, with a "start" button.

when clicked, it does so and so.

however, when its clicked, can it be changed to "cancel" and when that is clicked, it cancel's the currently running code, and changes back to "start" etc.

i know that autoit can set a button to being disabled, etc but can the button be changed? and then changed back once re-clicked?

Link to comment
Share on other sites

  • Moderators

royalmarine,

Just use GUICtrlSetData - the Help file has all the details. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

GUICreate("Button example", 100, 40)
$bButton = GUICtrlCreateButton("Start", 0, 0, 100, 40)
GUISetState()

$state = 0

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $bButton
            If $state Then
                $state = 0
                GUICtrlSetData($bButton, "Start")
            Else
                $state = 1
                GUICtrlSetData($bButton, "Cancel")
            EndIf
    EndSwitch

    If $state Then
        ; Do code
    EndIf
WEnd

Link to comment
Share on other sites

GUICreate("Button example", 100, 40)
$bButton = GUICtrlCreateButton("Start", 0, 0, 100, 40)
GUISetState()

$state = 0

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $bButton
            If $state Then
                $state = 0
                GUICtrlSetData($bButton, "Start")
            Else
                $state = 1
                GUICtrlSetData($bButton, "Cancel")
            EndIf
    EndSwitch

    If $state Then
        ; Do code
    EndIf
WEnd

cheers dude,

i was way off... :)

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("show/hide pic", 326, 288, 192, 124)
$Pic1 = GUICtrlCreatePic("", 8, 8, 308, 212, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$Show = GUICtrlCreateButton("show", 96, 240, 123, 41, $WS_GROUP)
$Hide = GUICtrlCreateButton("Hide", 96, 240, 123, 41, $WS_GROUP)
GUICtrlSetState($Hide, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Show
            GUICtrlSetState($Show, $GUI_DISABLE)
            GUICtrlSetState($Hide, $GUI_ENABLE)
            GUICtrlSetData $Pic1 = ('C:\Users\mike\Desktop\pic1.gif')
        Case $Hide
            GUICtrlSetState($Hide, $GUI_DISABLE)
            GUICtrlSetState($Show, $GUI_ENABLE)
            GUICtrlSetData $Pic1 = ('')

    EndSwitch
WEnd
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...