Jump to content

Help with "Disable/Gray out one tab"


Recommended Posts

  • Moderators

lgvlgv,

I do not believe you can "greyout" a tab - but you can prevent it being selected like this:

#include <GUIConstantsEx.au3>

Global $aTabs[5]

$hGUI = GUICreate("Test", 500, 500)

$cTab = GUICtrlCreateTab(10, 10, 480, 200)

For $i = 0 To 4
    $aTabs[$i] = GUICtrlCreateTabItem("Tab " & $i)
Next
GUICtrlCreateTabItem("")

GUICtrlCreateLabel("Select tab to disable", 10, 230, 200, 20)
$cCombo = GUICtrlCreateCombo("", 10, 250, 200, 20)
GUICtrlSetData($cCombo, "0|1|2|3|4")

GUISetState()

$iCurrDisabledTab = -1
$iCurrTab = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cCombo
            $iDisableTab = GUICtrlRead($cCombo)
            If $iDisableTab <> $iCurrDisabledTab Then
                If $iCurrDisabledTab <> -1 Then
                    GUICtrlSetData($aTabs[$iCurrDisabledTab], "Tab " & $iCurrDisabledTab)
                EndIf
                GUICtrlSetData($aTabs[$iDisableTab], "Disabled")
                $iCurrDisabledTab = $iDisableTab
            EndIf
        Case $cTab
            $iSelTab = GUICtrlRead($cTab)
            If $iSelTab = $iCurrDisabledTab Then
                GUICtrlSetState($aTabs[$iCurrTab], $GUI_SHOW)
            Else
                $iCurrTab = $iSelTab
            EndIf

    EndSwitch

WEnd
Please ask if you have any questions. :)

M23

Edit: I see you now have 2 versions to look at! :D

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

lgvlgv,

If you did not notice - they are both mine! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

lgvlgv,

If you did not notice - they are both mine! :D

M23

:)

Sorry dident see that :)

is there a way to chane the font color on specifyed tab, that would be enuff,my problem is that i dont have a variable when creating them, it looks like this..

and i want to change the color of the name of the tab depending of some conditions

Func _TCP_NewClient($iSocket, $sIP)
    ; We create a tab ctrl for the new client
    $oSrv.Send($iSocket, "~~who")

    ConsoleWrite("New Client!" & @CRLF)
    $sResult = _TCPIpToName($sIP)
    If @error Then
        ConsoleWrite( "Error: " & @error & " " & "@extended = " & @extended & @CRLF)
    Else
        ConsoleWrite($sIP & ": " & $sResult & @CRLF)
    EndIf

    $oSrv.ClientPropertySet($iSocket, 0, GUICtrlCreateTabItem($sResult))
    $oSrv.ClientPropertySet($iSocket, 1, GUICtrlCreateEdit("", 12, 120, 579, 200, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL), $WS_EX_STATICEDGE))
    $oSrv.ClientPropertySet($iSocket, 2, GUICtrlCreateInput("", 12, 330, 211, 21))
    $oSrv.ClientPropertySet($iSocket, 3, GUICtrlCreateButton("Send", 228, 330, 75, 21))
    $oSrv.ClientPropertySet($iSocket, 4, GUICtrlCreateButton("Disconnect", 312, 330, 75, 21))

    GUICtrlCreateTabItem("")
EndFunc   ;==>_TCP_NewClient
Edited by lgvlgv
Link to comment
Share on other sites

  • Moderators

lgvlgv,

The best I have ever been able to come up with is to change the background colour of the separate tabs - like this: :)

#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 (0)

; Create label to cover tab "tab"
Global $cColourTab = GUICtrlCreateLabel("", 0, 0, 1, 1, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN))

; Create tab
Global $cTab = GUICtrlCreateTab(5, 5,390, 290)
Global $cTab_Handle = GUICtrlGetHandle($cTab)

; Create tab items and colour them
For $i = 0 To 3
    GUICtrlCreateTabItem ("Tab item - " & $i)
    _GUICtrlTab_SetBkColor($hGUI, $cTab, $aTabColours[$i])
    GUICtrlCreateTabItem ("")
Next

_GUICtrlTab_SetCurSel($cTab_Handle,0)
_GUICtrlTab_SetCurFocus($cTab_Handle,0)
TabEvent()

GUISetState ()

While 1
    Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cTab
            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($cTab)
    ; Get coordinates of TabItem
    Local $aTab_Coord = _GUICtrlTab_GetItemRect($cTab_Handle, $iTab_Index)
    ; Get text of TabItem
    Local $sTab_Text = _GUICtrlTab_GetItemText($cTab_Handle, $iTab_Index)
    ; Place label
    GUICtrlSetPos($cColourTab, $iTab_X + $aTab_Coord[0] + $iTab_Margin, $iTab_Y + $aTab_Coord[1] + $iTab_Margin, $aTab_Coord[2] - $aTab_Coord[0] - ($iTab_Margin * 2), $aTab_Coord[3] - $aTab_Coord[1] - ($iTab_Margin * 2) + 5)
    ; Set text
    GUICtrlSetData($cColourTab, $sTab_Text)
    ; Set colour
    GUICtrlsetBkColor ($cColourTab,$aTabColours[$iTab_Index] )
    ; Set focus
    _GUICtrlTab_SetCurFocus($cTab_Handle,$iTab_Index)

EndFunc

Func _GUICtrlTab_SetBkColor($cWnd, $cSysTab32, $sBkColor)

    ; Get tab position
    Local $aTabPos = ControlGetPos($cWnd, "", $cSysTab32)
    ; Get size of user area
    Local $aTab_Rect = _GUICtrlTab_GetItemRect($cSysTab32, -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
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...