Jump to content

Color for Tabs?


Daveychan
 Share

Recommended Posts

Hello,

My apologies if this has been answered.. a search didn't find what i was looking for.

In Help, under "GUICtrlSetBkColor" it says that: "Only Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic and Progress controls can currently be colored."

Is there anyway around this? I've got a color scheme working that I like, but now I want to extend the functionality of my GUI, but when i add tabs, in lose the ability to change the colors the way i like.

Sorry for such a basic question, hopefully the answer is basic as well!

cheerz in advance!

daveychan

Link to comment
Share on other sites

Hello,

My apologies if this has been answered.. a search didn't find what i was looking for.

In Help, under "GUICtrlSetBkColor" it says that: "Only Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic and Progress controls can currently be colored."

Is there anyway around this? I've got a color scheme working that I like, but now I want to extend the functionality of my GUI, but when i add tabs, in lose the ability to change the colors the way i like.

Sorry for such a basic question, hopefully the answer is basic as well!

cheerz in advance!

daveychan

I think XSKin now has this functionality. Check the Example Scripts section. It's somewhere around there :whistle:

Link to comment
Share on other sites

  • 1 year later...

I think XSKin now has this functionality. Check the Example Scripts section. It's somewhere around there :)

I want to change the 'background' color of my tabs also.

I did a search through the AutoIt examples and could not find XSKin.

Could you please provide more details?

Thanx

Link to comment
Share on other sites

I want to change the 'background' color of my tabs also.

#include <GuiConstants.au3>
#include <GuiTab.au3>

$Gui = GUICreate("_GUICtrlTab_SetBkColor() Demo", 320, 280)

$hTab = GUICtrlCreateTab(10, 20, 300, 250)

GUICtrlCreateTabItem("Tab 1")
_GUICtrlTab_SetBkColor($Gui, $hTab, 0xFF0000)

GUICtrlCreateButton("Some Button", 20, 50)

GUICtrlCreateTabItem("Tab 2")
_GUICtrlTab_SetBkColor($Gui, $hTab, 0x00CC00)

GUICtrlCreateCheckbox("Some Checkbox", 20, 50)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor)
    Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32)
    
    Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1)
    
    GUICtrlCreateLabel("", $aTabPos[0]+2, $aTabPos[1]+$aTab_Rect[3]+4, $aTabPos[2]-4, $aTabPos[3]-$aTab_Rect[3]-7)
    GUICtrlSetBkColor(-1, $sBkColor)
    GUICtrlSetState(-1, $GUI_DISABLE)
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 1 month later...

Hmm, its nice until you try and use something simple like GUICtrlCreateGraphic on a coloured tab...fails, manily because the tab background is a label now...

Surely theres got to be a way to colour the tab without rendering other controls useless?

Anyone?

Link to comment
Share on other sites

Hmm, its nice until you try and use something simple like GUICtrlCreateGraphic on a coloured tab...fails, manily because the tab background is a label now...

Surely theres got to be a way to colour the tab without rendering other controls useless?

Anyone?

Can you give an example of a graphic on a tab without the coloured label?

BTW the end tabitem definition is missing from the example above.(GUICtrlCreateTabItem("") )

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.
Link to comment
Share on other sites

Can you give an example of a graphic on a tab without the coloured label?

BTW the end tabitem definition is missing from the example above.(GUICtrlCreateTabItem("") )

Okay, take something this simple:

#include <GuiConstants.au3>
$hGUI = GUICreate("", 300, 200)

$hTab = GUICtrlCreateTab(10, 10, 280, 180)
$TabItem1 = GUICtrlCreateTabItem("TabItem 1")
GUICtrlCreateGraphic(20, 80, 14,14, $SS_SUNKEN)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_ONTOP)
GUICtrlSetBkColor(-1, 0xff04ff)
$TabItem2 = GUICtrlCreateTabItem("TabItem 2")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Then try the commonly used method of colouring the tabs, which is turning the background into a label, and the GUICtrlCreateGraphic part fails.....

Link to comment
Share on other sites

Okay, take something this simple:

#include <GuiConstants.au3>
$hGUI = GUICreate("", 300, 200)

$hTab = GUICtrlCreateTab(10, 10, 280, 180)
$TabItem1 = GUICtrlCreateTabItem("TabItem 1")
GUICtrlCreateGraphic(20, 80, 14,14, $SS_SUNKEN)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_ONTOP)
GUICtrlSetBkColor(-1, 0xff04ff)
$TabItem2 = GUICtrlCreateTabItem("TabItem 2")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Then try the commonly used method of colouring the tabs, which is turning the background into a label, and the GUICtrlCreateGraphic part fails.....

Here's a way to do what you want

;modified from Example of TAB in TAB ctrl by aec in AutoIt post
#include <GUIConstants.au3>

Global $main_GUI,$ok_button,$cancel_button

;This window has 2 ok/cancel-buttons
$main_GUI       = GUICreate("TAB in TAB",260,250,-1,-1)
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$cancel_button  = GUICtrlCreateButton("Cancel",150,220,70,20)

; Create the first child window that is implemented into the main GUI
$child1         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$child_tab      = GUICtrlCreateTab(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("1")
$child12tab     = GUICtrlCreateTabItem("2")
GUICtrlCreateTabItem("")

GUISetState()

; Create the second child window that is implemented into the main GUI
$child2         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$labBkGround        =  GUICtrlCreateLabel("",0,0,230,170,$WS_CLIPSIBLINGS);GUICtrlCreateListView("Col1|Col2",10,10,210,150,-1,$WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1,0xff0000)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateGraphic(20, 80, 14,14, $SS_SUNKEN)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_ONTOP)
GUICtrlSetBkColor(-1, 0xff04ff)

; Switch back the main GUI and create the tabs
GUISwitch($main_GUI)
$main_tab       = GUICtrlCreateTab(10,10,240,200)
$child1tab      = GUICtrlCreateTabItem("Child1")
$child2tab      = GUICtrlCreateTabItem("Child2")
GUICtrlCreateTabItem("")

GUISetState()
$HideShow = $GUI_HIDE + $GUI_SHOW
$chil1tabstate = true

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $cancel_button
            $chil1tabstate = not $chil1tabstate
            If $chil1tabstate Then
              GUISetState(@SW_ENABLE,$child2)
              Else
               GUISetState(@SW_DISABLE ,$child2)
              EndIf
                  
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
                  GUISetState(@SW_HIDE,$child2)
                  GUISetState(@SW_SHOW,$child1)
          
                Case 1
                  GUISetState(@SW_HIDE,$child1)
                  If $chil1tabstate Then GUISetState(@SW_SHOW,$child2)
            EndSwitch
    EndSwitch
WEnd
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.
Link to comment
Share on other sites

Here's a way to do what you want

;modified from Example of TAB in TAB ctrl by aec in AutoIt post
#include <GUIConstants.au3>

Global $main_GUI,$ok_button,$cancel_button

;This window has 2 ok/cancel-buttons
$main_GUI       = GUICreate("TAB in TAB",260,250,-1,-1)
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$cancel_button  = GUICtrlCreateButton("Cancel",150,220,70,20)

; Create the first child window that is implemented into the main GUI
$child1         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$child_tab      = GUICtrlCreateTab(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("1")
$child12tab     = GUICtrlCreateTabItem("2")
GUICtrlCreateTabItem("")

GUISetState()

; Create the second child window that is implemented into the main GUI
$child2         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$labBkGround        =  GUICtrlCreateLabel("",0,0,230,170,$WS_CLIPSIBLINGS);GUICtrlCreateListView("Col1|Col2",10,10,210,150,-1,$WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1,0xff0000)
GUICtrlSetState(-1,$GUI_DISABLE)
GUICtrlCreateGraphic(20, 80, 14,14, $SS_SUNKEN)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_ONTOP)
GUICtrlSetBkColor(-1, 0xff04ff)

; Switch back the main GUI and create the tabs
GUISwitch($main_GUI)
$main_tab       = GUICtrlCreateTab(10,10,240,200)
$child1tab      = GUICtrlCreateTabItem("Child1")
$child2tab      = GUICtrlCreateTabItem("Child2")
GUICtrlCreateTabItem("")

GUISetState()
$HideShow = $GUI_HIDE + $GUI_SHOW
$chil1tabstate = true

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $cancel_button
            $chil1tabstate = not $chil1tabstate
            If $chil1tabstate Then
              GUISetState(@SW_ENABLE,$child2)
              Else
               GUISetState(@SW_DISABLE ,$child2)
              EndIf
                  
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
                  GUISetState(@SW_HIDE,$child2)
                  GUISetState(@SW_SHOW,$child1)
          
                Case 1
                  GUISetState(@SW_HIDE,$child1)
                  If $chil1tabstate Then GUISetState(@SW_SHOW,$child2)
            EndSwitch
    EndSwitch
WEnd

Thanks for that, it does work, but sheesh, you would hope there was an easier way wouldnt you lol.

Thanks again

p.s. This came about due to using a custom pie control on a tab, the custom control doesnt match its background to the tab control when using the windows xp theme, so thats the reason i was altering the background. While tearing my hair out ive been using the following workaround at the top of my script to turn the windows xp theme off...back to classic :0

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...