Function Reference

GUICtrlSetBkColor

Sets the background color of a control.

GUICtrlSetBkColor ( controlID, backgroundcolor )

 

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate... function.
backgroundcolor The RGB color to use.

 

Return Value

Success: Returns 1.
Failure: Returns 0.

 

Remarks

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic, Progress and Slider controls can currently be colored.

Progress controls cannot be painted if the "Windows XP style" is used.

Button controls are always painted in "Windows Classic style". They cannot have the $BS_ICON style.

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

The special flag $GUI_BKCOLOR_TRANSPARENT can be used with label control to give them a transparent background. Picture controls have always a transparent color.

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.
The odd lines will get the color set by GUICtrlSetBkColor of the Listview control.
The even lines will get the color set by GUICtrlSetBkColor of the ListviewItem control.

 

Related

ColorMode (Option), GUICtrlCreate..., GUICtrlSetColor, GUICtrlSetDefBkColor

 

Example


#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $msg
   
    GUICreate("My GUI background color")  ; will create a dialog box that when displayed is centered

    GUICtrlCreateLabel("my label", 10, 20)
    GUICtrlSetBkColor(-1, 0x00ff00)     ; Green
   
    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
       
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example