$I ColorButton.inc

Windowstyle 24
Windowtitle "Demo ColorButton.inc"
Window 100,200-300,200

Declare L#,Sz&, color_&
Dim L#, 3*4
Long L#,0 =width(%hwnd)\3,(width(%hwnd)\3)*2,-1
Sz& = @Create("StatusWindow",%HWND,"",3,L#)
var colorbutton1&=CreateColorButton(%hwnd,RGB(255,0,0),5,5,width(%hwnd)/3-10,height(%hwnd)-32)
var colorbutton2&=CreateColorButton(%hwnd,RGB(0,255,150),5+width(%hwnd)/3,5,width(%hwnd)/3-10,height(%hwnd)-32)

var colorbutton3&=CreateColorButton(%hwnd,RGB(0,0,255),(width(%hwnd)/3)*2+5,5,width(%hwnd)/3-10,(height(%hwnd)-35)/2)
var colorbutton4&=CreateColorButton(%hwnd,RGB(255,255,0),(width(%hwnd)/3)*2+5,(height(%hwnd)-11)/2-6,width(%hwnd)/3-10,(height(%hwnd)-32)/2)

SetText Sz&, 0, "Color: "+Str$(ColorButton.GetColor(colorbutton1&))
SetText Sz&, 1, "Color: "+Str$(ColorButton.GetColor(colorbutton2&))
SetText Sz&, 2, "© by J.Schmidt"
while 1
    waitinput
    if getfocus(colorbutton1&)
        SetText Sz&, 0, "Color: "+Str$(ColorButton.SetRandomCol(colorbutton1&))
        waitinput
    elseif getfocus(colorbutton2&)
        color_&=ChooseColor(%hwnd,ColorButton.GetColor(colorbutton2&))
        case color_&<>-1 : ColorButton.SetColor(colorbutton2&,color_&)
        SetText Sz&, 1, "Color: "+Str$(ColorButton.GetColor(colorbutton2&))
    Endif
Endwhile
