Jump to content

Labels on Tabs - appearing on all tabs


Recommended Posts

Hello everyone!

I have a small problem that I cant find the answer to:

I have a simple script which, using GuiCtrlCreateTab, with default parameters, creates 5 tabs for me. On one tab I call a function to perform some task, this all works fine. The function returns and creates 2 labels of information at certain locations on my gui. My problem, is that now ALL tabs have these labels on them as my function has defined the x & y coords and I was wondering:

Is it possible to define these labels so that they only appear on my current active tab?

I can't find this answer either in the help nor on the forum - though I do admit my search criteria may possibly be pants! If some one has a forum link to an answer or could help me out I'd be greatful.

Many thanks for your time

Jon

:)

Link to comment
Share on other sites

I guess it's better to post the script

but any way u can define a var name for each tab item

$tab_1 = GUICtrlCreateTabItem ("tab 1")
Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

check if this example can help u

#include <GUIConstants.au3>
GUICreate("test", 350, 160)
GUICtrlCreateTab (5,5,340,100)
$tab_1 = GUICtrlCreateTabItem ("tab 1")
$lable = GUICtrlCreateLabel ("", 20,60,300,30)
$tab_2 = GUICtrlCreateTabItem ("tab 2")
$tab_3 = GUICtrlCreateTabItem ("tab 3")
$tab_4 = GUICtrlCreateTabItem ("tab 4")
GUICtrlCreateTabItem ("")
$t = GUICtrlCreateButton ("test",5,120,340,25)
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $t Then
        $in = InputBox ("put data" ,"insert text" ,"", "", 100,40,-1,-1,20)
    GUICtrlSetData ($lable , $in)
    EndIf
WEnd
Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

Hi,

Nice example star2 :)

CheifDruid maybe you could create the labels when first running the gui.

Then use your function to just set data in the already created label as needed.

Here was my effort for an example, as usual it's over bloated ..lol

It contains 2 labels and static combobox per tab. Can set or clear a label on the current tab or on the tabs not currently in use by selecting the item in the combobox.

#include <GUIConstants.au3>
  
Global $Tabs[6][4]

GUICreate("Tab Labels", 229, 160, -1,-1)
$Tabs[0][0] = GUICtrlCreateTab (5, 5, 219,150)
For $t = 1 To 5
    $Tabs[$t][0] = GUICtrlCreateTabitem ("Tab " & $t)
    $Tabs[$t][1] = GUICtrlCreateLabel("", 14, 30, 90, 20, $BS_CENTER)
    $Tabs[$t][2] = GUICtrlCreateLabel("", 109, 30, 100, 20, $BS_CENTER)
    $Tabs[$t][3] = GUICtrlCreateCombo("Set both Tab " & $t & " Labels to blank", 13, 55, 200, 20, $CBS_DROPDOWNLIST)
    GuiCtrlSetData($Tabs[$t][3], "Tab_1 Label_1|Tab_1 Label_2|Tab_2 Label_1|Tab_2 Label_2|Tab_3 Label_1|Tab_3 Label_2|" & _
                                    "Tab_4 Label_1|Tab_4 Label_2|Tab_5 Label_1|Tab_5 Label_2|Set All Tabs Labels to blank")
Next
GUISetState ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    For $b = 1 To 5
        Select
            Case $msg = $Tabs[$b][3]
                AssignToLabel($B)
        EndSelect
    Next
Wend

Func AssignToLabel($n)
    If GuiCtrlRead($Tabs[$n][3]) = "Set both Tab " & $n & " Labels to blank" Then
        GuiCtrlSetData($Tabs[$n][1], '')
        GuiCtrlSetData($Tabs[$n][2], '')
    ElseIf GuiCtrlRead($Tabs[$n][3]) = "Set All Tabs Labels to blank" Then
        For $d = 1 To 5
            GuiCtrlSetData($Tabs[$d][1], '')
            GuiCtrlSetData($Tabs[$d][2], '')
        Next
    EndIf
    For $p = 1 To 5
        For $l = 1 To 2
            If GuiCtrlRead($Tabs[$n][3]) = "Tab_" & $p & " Label_" & $l Then
                GuiCtrlSetData($Tabs[$p][$l], GuiCtrlRead($Tabs[$n][3]))
            EndIf
        Next
    Next
EndFunc

Cheers

Edited by smashly
Link to comment
Share on other sites

Smashly / star2 You are both STARS! :)

Both examples work a treat, (I'm spoilt for choice as to which route I should take!).

I'm finding AutoIT to be a pleasant learning curve, which goes to prove - 'you can teach an old dog new tricks!'

My sincere thanks

Kind regards

Jon

:)

Link to comment
Share on other sites

Smashly / star2 You are both STARS! :)

Jon

:)

CheifDruid u are so welcome

Smashly nice job :)

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

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