Sign in to follow this  
Followers 0
itrn007

Help with Toggle Button

3 posts in this topic

I am struggling with how to make a button APPEAR to be toggled. That is, when clicked once it will appear to be "pressed" or selected in some way, and when click again it will appear to be unpressed. This would be similar in function to the bold button on a word processor toolbar - it would stay "pressed" until clicked again.

I am OK with the code behind the the states/actions. It is more the visuals that I am looking for

Thanks all in advance.

Share this post


Link to post
Share on other sites



This?

#include <GuiConstants.au3>

$hGui = GUICreate("Test to toggle", 200, 100)

$button = GUICtrlCreateCheckbox("Toggle", 10, 70, 50, 25, $BS_PUSHLIKE)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $button
        Switch GUICtrlRead($button)
        Case $GUI_CHECKED
            ConsoleWrite("Button pressed" & @CRLF)
        Case $GUI_UNCHECKED
            ConsoleWrite("Button unpressed" & @CRLF)
        EndSwitch
        
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Perfect! Exactly what i needed. I think the $BS_PUSHLIKE is the piece I was missing.

Thanks!

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