Sign in to follow this  
Followers 0
jacQues

Radio that looks like a button with colour.

3 posts in this topic

Simplified code:

DIM $button[11]

$button[0] = 10

GUICtrlCreateGroup(...)

FOR $x = 1 TO $button[0]

$button[$x] = GUICtrlCreateRadio(...,$BS_PUSHLIKE) ; style 0x1000

GUICtrlSetBkColor($button[$x],0x7F7FFF) ; blue background

NEXT

It shows ten radiobuttons in the GUI that look like buttons. However, GUICtrlSetBkColor() doesn't work. When I use $BS_CHECKBOX (style 0x0002) instead the colours do change as expected. Thus, are colours simply disables with $BS_PUSHLIKE or do I need to add another style or extended style to make it work?

jacQues

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Simplified code:

DIM $button[11]

$button[0] = 10

GUICtrlCreateGroup(...)

FOR $x = 1 TO $button[0]

$button[$x] = GUICtrlCreateRadio(...,$BS_PUSHLIKE) ; style 0x1000

GUICtrlSetBkColor($button[$x],0x7F7FFF) ; blue background

NEXT

It shows ten radiobuttons in the GUI that look like buttons. However, GUICtrlSetBkColor() doesn't work. When I use $BS_CHECKBOX (style 0x0002) instead the colours do change as expected. Thus, are colours simply disables with $BS_PUSHLIKE or do I need to add another style or extended style to make it work?

jacQues

I don't think you can do that without making an owner drawn button.

You could do something like this maybe

#include <windowsconstants.au3>
#include <buttonconstants.au3>

$gui = GUICreate("bcol")
GUICtrlCreateGroup("radios", 5, 5)
$b1 = GUICtrlCreateButton("one", 20, 20, 100, 21)
GUICtrlSetBkColor(-1, 0x7F7FFF)
$b2 = GUICtrlCreateButton("two", 20, 40, 100, 21)
GUICtrlSetBkColor(-1, 0x7F7FFF)
$b3 = GUICtrlCreateButton("three", 20, 60, 100, 21)
GUICtrlSetBkColor(-1, 0x7F7F7F)
GUICtrlCreateGroup("", -99, -99, 1, 1);close group
$pressed = $b1
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case - 3
            Exit
        Case $b1 To $b3
            For $n = $b1 To $b3
                If $n <> $msg Then                  
                    GUICtrlSetBkColor($n, 0x7F7FFF)
                Else
                    GUICtrlSetBkColor($n, 0x7F7F7F)
                EndIf
            Next
            $pressed = $n
    EndSwitch
    
WEnd
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I don't think you can do that without making an owner drawn button.

You could do something like this maybe

Right, not possible with pure radio buttons so. :-(

Thanks for the workaround; I'll adapt something alike your code for my software.

jacQues

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