Sign in to follow this  
Followers 0
muncherw

Background color in tabs

5 posts in this topic

I have tab with several items in it. The bacground to my gui is a light blue and I'd like the background of the tabs to be the same but can't figure out how to do it. A picture has been added so you can see what I'm talking about. Any suggestions? I've tried GUISetBkColor and GUICtrlSetBkColor with no luck.

Posted Image


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
Share on other sites



AutoIt code is using the basic windows API and this coloring is not possible. Doc is clear on the fact that tab cannot be painted :D

Share this post


Link to post
Share on other sites

AutoIt code is using the basic windows API and this coloring is not possible. Doc is clear on the fact that tab cannot be painted :D

Very good. Thanks! Appreciate the help.


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
Share on other sites

Very good. Thanks! Appreciate the help.

But there are a couple of work-arounds.

One way which can give a satisfactory result is to have a label with no text and with the correct colour covering the area where there is no tab. If you do this you might want to adjust the position of the label depending on whether the end tab is selected or not, but the variation in the gap between the last tab and the label might not be be a concern.

The second way is to increase the tab widths so that there is no gap with the wrong colour.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $tab, $tab0, $tab0OK, $tab0input
    Local $tab1, $tab1combo, $tab1OK
    Local $tab2, $tab2OK, $msg, $labcover

    GUICreate("My GUI Tab"); will create a dialog box that when displayed is centered

    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)

    $tab = GUICtrlCreateTab(10, 10, 200, 100)

    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)

    $tab1 = GUICtrlCreateTabItem("tab----1")
    GUICtrlCreateLabel("label1", 30, 70, 50, 20)

    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW); will be display first

    GUICtrlCreateTabItem(""); end tabitem definition
    $labcover = GUICtrlCreateLabel("", 154, 10, 80, 22)
    GUICtrlSetBkColor(-1, 0x00E0FFFF)

    GUISetState()

   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        If $msg = $tab Then
            If GUICtrlRead($tab) = 2 Then
                ControlMove("My GUI Tab", "", $labcover, 154, 10)
            Else
                ControlMove("My GUI Tab", "", $labcover, 150, 10)
            EndIf
        EndIf

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc  ;==>Example

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <tabconstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $tab, $tab0, $tab0OK, $tab0input
    Local $tab1, $tab1combo, $tab1OK
    Local $tab2, $tab2OK, $msg, $labcover

    GUICreate("My GUI Tab"); will create a dialog box that when displayed is centered

    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)

    $tab = GUICtrlCreateTab(10, 10, 200, 100,$TCS_FIXEDWIDTH);must have fixed width to be able to set tab widths
    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)

    $tab1 = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateLabel("label1", 30, 70, 50, 20)

    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW); will be display first

    GUICtrlCreateTabItem(""); end tabitem definition
   

    GUISetState()
GuictrlSendMsg($Tab, $TCM_SETITEMSIZE, 0, _MakeLong(65, 20))
   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
       

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc  ;==>Example

Func _MakeLong($l, $h)
    Return BitOR(BitAnd($l, 0xFFFF), BitShift(BitAnd($h, 0xFFFF), -16))
EndFunc; _MakeLong()

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.

Share this post


Link to post
Share on other sites

Some interesting ideas, Martin. I think I'll give them a try. Your examples were good, thanks.


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
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
Sign in to follow this  
Followers 0