#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
$hGUI = GUICreate('_GUICtrlCreateColoredLabel')
$iCheckBox1 = GUICtrlCreateCheckbox('', 10, 25, 20, 20)
$aLabel1 = _GUICtrlCreateColoredLabel('Lorem Ipsum', 40, 10, 330, 50, 0x2CA1E6, 0xFFFFFF, 0xAB5554, True)
$iCheckBox2 = GUICtrlCreateCheckbox('', 10, 85, 20, 20)
$aLabel2 = _GUICtrlCreateColoredLabel('Ipsum Lorem', 40, 70, 330, 50, 0xAB5554, 0xFFFFFF, 0x2CA1E6, False)
GUISetState(@SW_SHOW, $hGUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $aLabel1[0]
ConsoleWrite('Left Label Part Clicked' & @CRLF)
_ToggleCheckBox($iCheckBox1)
Case $aLabel1[1]
ConsoleWrite('Center Label Part Clicked' & @CRLF)
_ToggleCheckBox($iCheckBox1)
Case $aLabel1[2]
ConsoleWrite('Right Label Part Clicked' & @CRLF)
_ToggleCheckBox($iCheckBox1)
Case $aLabel1[3]
_ToggleCheckBox($iCheckBox1)
Case $aLabel2[0] To $aLabel2[3]
_ToggleCheckBox($iCheckBox2)
EndSwitch
WEnd
Func _GUICtrlCreateColoredLabel($sText, $iLeft, $iTop, $iWidth, $iHeight, $iLeftColor, $iCenterColor, $iRightColor, $bNotifyColors = False, $iLblSize = 20, $iLblWeight = 800)
Local $iPart1_Width = Floor($iWidth / 2.6)
Local $iPart2_Width = Floor($iWidth / 8)
Local $iPart3_Width = Floor($iWidth / 2.02)
Local $aRet[4]
$aRet[0] = GUICtrlCreateLabel('', $iLeft, $iTop, $iPart1_Width, $iHeight)
GUICtrlSetBkColor(-1, $iLeftColor)
GUICtrlSetState(-1, ($bNotifyColors ? $GUI_ENABLE : $GUI_DISABLE))
$aRet[1] = GUICtrlCreateLabel('', $iLeft + $iPart1_Width, $iTop, $iPart2_Width, $iHeight)
GUICtrlSetBkColor(-1, $iCenterColor)
GUICtrlSetState(-1, ($bNotifyColors ? $GUI_ENABLE : $GUI_DISABLE))
$aRet[2] = GUICtrlCreateLabel('', $iLeft + $iPart1_Width + $iPart2_Width, $iTop, $iPart3_Width, $iHeight)
GUICtrlSetBkColor(-1, $iRightColor)
GUICtrlSetState(-1, ($bNotifyColors ? $GUI_ENABLE : $GUI_DISABLE))
$aRet[3] = GUICtrlCreateLabel($sText, $iLeft, $iTop, $iWidth, $iHeight, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, $iLblSize, $iLblWeight)
Return $aRet
EndFunc
Func _ToggleCheckBox($iCheckBox)
GUICtrlSetState($iCheckBox, BitAND(GUICtrlRead($iCheckBox), $GUI_CHECKED) ? $GUI_UNCHECKED : $GUI_CHECKED)
EndFunc