acidman Posted February 22, 2012 Posted February 22, 2012 Is it possible to color the background of a tab within a tab control, no style has been pre-loaded to color the background in koda Gui designer, need some help please! [u]My dream is to have a dream...[/u]
Moderators Melba23 Posted February 22, 2012 Moderators Posted February 22, 2012 ac1dm4nner, This is based on some original code by Valik, so most of the credit should go to him: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTab.au3> #include <StaticConstants.au3> ; Tab colours Global $aTabColours[4] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0] ; Create GUI Global $hGUI = GUICreate ("Test", 400,300) GUISetBkColor (0xFFFF00) ; Create label to cover Tab "tab" Global $hColourTab = GUICtrlCreateLabel("", 0, 0, 1, 1, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN)) ; Create tab Global $hTab = GUICtrlCreateTab(5, 5,390, 290) Global $hTab_Handle = GUICtrlGetHandle($hTab) ; Create Tab items and colour them For $i = 0 To 3 GUICtrlCreateTabItem ("Tab item - " & $i) _GUICtrlTab_SetBkColor($hGUI, $hTab, $aTabColours[$i]) GUICtrlCreateTabItem ("") Next _GUICtrlTab_SetCurSel($hTab_Handle,0) _GUICtrlTab_SetCurFocus($hTab_Handle,0) TabEvent() GUISetState () While 1 Switch GUIGetMsg () Case $GUI_EVENT_CLOSE Exit Case $hTab TabEvent() EndSwitch WEnd Func TabEvent() ; Set values Local $iTab_X = 5, $iTab_Y = 5, $iTab_Margin = 1 ; Get index of current tab Local $iTab_Index = GUICtrlRead($hTab) ; Get coordinates of TabItem Local $aTab_Coord = _GUICtrlTab_GetItemRect($hTab_Handle, $iTab_Index) ; Get text of TabItem Local $sTab_Text = _GUICtrlTab_GetItemText($hTab_Handle, $iTab_Index) ; Place label GUICtrlSetPos($hColourTab, $iTab_X + $aTab_Coord[0] + $iTab_Margin, $iTab_Y + $aTab_Coord[1] + $iTab_Margin + 1, $aTab_Coord[2] - $aTab_Coord[0] - ($iTab_Margin * 2), $aTab_Coord[3] - $aTab_Coord[1] - ($iTab_Margin * 2) + 5) ; Set text GUICtrlSetData($hColourTab, $sTab_Text) ; Set colour GUICtrlsetBkColor ($hColourTab,$aTabColours[$iTab_Index] ) ; Set focus _GUICtrlTab_SetCurFocus($hTab_Handle,$iTab_Index) EndFunc Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor) ; Get Tab position Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32) ; Get size of user area Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1) ; Create label GUICtrlCreateLabel("", $aTabPos[0] + 2, $aTabPos[1] + $aTab_Rect[3] + 4, $aTabPos[2] - 6, $aTabPos[3] - $aTab_Rect[3] - 7) ; colour label GUICtrlSetBkColor(-1, $sBkColor) ; Disable label GUICtrlSetState(-1, $GUI_DISABLE) EndFunc ;==>_GUICtrlTab_SetBkColor I am afraid there is no simpler way! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
acidman Posted April 6, 2012 Author Posted April 6, 2012 Damn this is beautiful. just what i have been looking for Thanks melba and valik! [u]My dream is to have a dream...[/u]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now