Hintergrundfarbe eines TabItems ändern.

  • Hi @all,

    ich habe ein TabItem erstellt:

    $ts_ConfigFiles = GUICtrlCreateTabItem('Config')

    Leider schaffe ich es nicht, die Hintergrundfarbe zu ändern. Es ist weiß und ich möchte es grau haben (wie die Standard Gui Farbe)
    Weder GUICtrlSetBkColor noch GUISetBkColor haben funktioniert.

    Hoffe jemand hat Rat ;)

    Danke und Gruß
    Herra

  • Tabs sind WindowsControls und keine AutoitControls, deshalb funktioniert GuiCtrlSetBkColor nicht.

    https://autoit.de/index.php?page=Thread&postID=40747

    wenn deine Tabs weiß sind, dann ist das wahrscheinlich in Windows so eingestellt:
    Desktop -> Rechtsklick -> Eigenschaften -> Darstellung -> Erweitert...
    (also ich nehm mal an, daß auf deinem Rechner auch Tabs von anderen Programmen weiß sind, oder?!)

    lgE

  • Hi,

    aber mit etwas Aufwand:

    Spoiler anzeigen
    [autoit]


    ; http://www.autoitscript.com/forum/index.ph…TabItem+colored
    #include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GuiTab.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $ODT_TAB = 101
    Global Const $ODS_SELECTED = 0x0001
    Global Const $ODA_DRAWENTIRE = 0x1

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $ODS_FOCUS = 0x0010

    [/autoit] [autoit][/autoit] [autoit]

    $hGUI = GUICreate("Draw Tab", 300, 200)

    [/autoit] [autoit][/autoit] [autoit]

    $hTab = GUICtrlCreateTab(10, 10, 280, 180, $TCS_OWNERDRAWFIXED)

    [/autoit] [autoit][/autoit] [autoit]

    $TabItem_1 = GUICtrlCreateTabItem("TabItem 1")
    GUICtrlCreateLabel("", 10, 33, 277, 155)
    GUICtrlSetBkColor(-1, 0xDDAA11)
    GUICtrlSetState(-1, $GUI_DISABLE)

    [/autoit] [autoit][/autoit] [autoit]

    $TabItem_2 = GUICtrlCreateTabItem("TabItem 2")
    GUICtrlCreateLabel("", 10, 33, 277, 155)
    GUICtrlSetBkColor(-1, 0x99BBEE)
    GUICtrlSetState(-1, $GUI_DISABLE)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateTabItem("")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM")

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlTab_SetCurSel($hTab, 1)
    _GUICtrlTab_SetCurSel($hTab, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = -3

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam)
    Local $DRAWITEMSTRUCT

    $DRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _
    "hwnd hItm;hwnd hDC;dword itmRect[4];dword itmData", $lParam)

    If DllStructGetData($DRAWITEMSTRUCT, "cType") <> $ODT_TAB Then Return $GUI_RUNDEFMSG

    Local $cID = DllStructGetData($DRAWITEMSTRUCT, "cID")
    Local $itmID = DllStructGetData($DRAWITEMSTRUCT, "itmID")
    Local $itmAction = DllStructGetData($DRAWITEMSTRUCT, "itmAction")
    Local $itmState = DllStructGetData($DRAWITEMSTRUCT, "itmState")
    Local $hItm = DllStructGetData($DRAWITEMSTRUCT, "hItm")
    Local $hDC = DllStructGetData($DRAWITEMSTRUCT, "hDC")

    If $itmAction <> $ODA_DRAWENTIRE Then Return $GUI_RUNDEFMSG

    Local $iTextColor, $itmText

    Switch $itmID
    Case 0
    $iBrushColor = 0x11AADD
    Case 1
    $iBrushColor = 0xEEBB99
    EndSwitch

    DLLCall("gdi32.dll","int","SetBkMode", "hwnd", $hDC, "int", 1)

    Local $iBrush = DLLCall("gdi32.dll","hwnd","CreateSolidBrush", "int", $iBrushColor)
    $iBrush = $iBrush[0]

    Local $iBrushOld = _WinAPI_SelectObject($hDC, $iBrush)

    DLLCall("user32.dll","int","FillRect", "hwnd", $hDC, "ptr", DllStructGetPtr($DRAWITEMSTRUCT, "itmRect"), "hwnd", $iBrush)

    Local $tBuffer = DllStructCreate("char[256]")
    DllStructSetData($tBuffer, 1, "Item" & $itmID)
    $itmText = DllStructGetData($tBuffer, 1)

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($DRAWITEMSTRUCT, "itmRect", DllStructGetData($DRAWITEMSTRUCT, "itmRect", 1) + 10, 1)
    DllStructSetData($DRAWITEMSTRUCT, "itmRect", DllStructGetData($DRAWITEMSTRUCT, "itmRect", 2) + 5, 2)

    DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "str", $itmText, "int", StringLen($itmText), _
    "ptr", DllStructGetPtr($DRAWITEMSTRUCT, "itmRect"), "int", $DT_LEFT)

    _WinAPI_SelectObject($hDC, $iBrushOld)
    _WinAPI_DeleteObject($iBrush)

    Return $GUI_RUNDEFMSG
    EndFunc

    [/autoit]


    Viel Erfolg!

  • OK, das funktioniert doch eingentlich ganz gut!

    jedoch hab ich das Gefühl, daß das irgendwie anders gehen muß.

    bei AutoHotKey geht das mit 3 Zeilen:

    Code
    Gui, Color, FFAA00
    Gui, Add, Tab2,, Tab1|Tab2|Tab3
    Gui, Show

    Macht AHK intern dasselbe wie RR04´s Beispiel, oder gibt es die Funktion Tab-Einfärben, muß jedoch erst in Autoit implementiert werden?!?

    lgE

  • Hier habe ich es mal an einem Script aus der Hilfe gemacht ! ;)

    TabItem colored
    [autoit]


    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    Example()

    [/autoit] [autoit][/autoit] [autoit]

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

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

    [/autoit] [autoit][/autoit] [autoit]

    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)
    $tab = GUICtrlCreateTab(10, 10, 200, 100)

    [/autoit] [autoit][/autoit] [autoit]

    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab0OK = GUICtrlCreateButton("OK0", 20, 50, 50, 20)
    $tab0input = GUICtrlCreateInput("default", 80, 50, 70, 20)

    ; START ### Change by RR04 ###############################################################
    $tab1 = GUICtrlCreateTabItem("tab----1")
    GUICtrlCreateLabel("", 12, 33, 197, 76)
    GUICtrlSetBkColor(-1, 0xDDAA11)
    GUICtrlSetState(-1, $GUI_DISABLE)
    ; ENDE ### Change by RR04 ################################################################

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab1combo = GUICtrlCreateCombo("", 20, 50, 60, 120)
    GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon"); default Jon
    $tab1OK = GUICtrlCreateButton("OK1", 80, 50, 50, 20)

    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW); will be display first
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    $tab2OK = GUICtrlCreateButton("OK2", 140, 50, 50)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateTabItem(""); end tabitem definition
    GUICtrlCreateLabel("Click on tab and see the title", 20, 130, 250, 20)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $tab Then
    ; display the clicked tab
    WinSetTitle("My GUI Tab", "", "My GUI Tab" & GUICtrlRead($tab))
    EndIf
    WEnd
    EndFunc ;==>Example

    [/autoit]


    Viel Erfolg ! ^^

  • Vllt. is das nur wieder ein Problem mit dem XP-Style? Hast du schon probiert den abzuschalten?

    Projekte: Keine größeren (und fertigen)
    Gegen Internetzensur:
    https://epetitionen.bundestag.de/index.php?acti…s;petition=3860
    (Zeichnungsfrist abgelaufen)
    __________________________________________________________________________________________________________________________________
    Dieser Beitrag wurde bereits 264 mal editiert, zuletzt von »Fast2« (30. Februar 2009, 12:99)