Jump to content
Sign in to follow this  
Polyphem

GUICtrlCreateTab with $TCS_BUTTONS

Recommended Posts

Polyphem

HiHo,

recently changed the style of a Tab control to $TCS_BUTTONS (i like that style muttley ). But now i cant find a way to properly set focus to the tab anymore, with _GUICtrlTab_SetCurFocus($tab, 1) the button is pressed but the tabs content is not displayed. Anyone got a hint for me?

Cheers


This post will be edited again by Polyphem: Tomorrow, 11:55 AM

Share this post


Link to post
Share on other sites
rasim

Polyphem

To select a tab use the _GUICtrlTab_SetCurSel() function.

Share this post


Link to post
Share on other sites
Polyphem

@rasim: Thanks for your reply. But _GUICtrlTab_SetCurFocus($tab, 1) is what did the trick for me on a Tab control without the $TCS_BUTTONS style set. Tried that AND _GUICtrlTab_SetCurSel($tab, 1) both on the style, neither works. Below is a sample code. GUI one behaves like i want, GUI two doesnt. The only difference between the two functions is the tab style...

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

Example_Tab_without_TCS_BUTTONS()

Example_Tab_with_TCS_BUTTONS()

Func Example_Tab_without_TCS_BUTTONS()
    GUICreate("My GUI Tab", 250, 150)
    $tab = GUICtrlCreateTab(10, 10, 200, 100)
    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab1 = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    GUISetState()
    
    _GUICtrlTab_SetCurFocus($tab, 1)
    ;_GUICtrlTab_SetCurSel($tab, 1)
        
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            ExitLoop
            GUIDelete (-1)
        endif
    WEnd
EndFunc

Func Example_Tab_with_TCS_BUTTONS()
    GUICreate("My GUI Tab", 250, 150)
    $tab = GUICtrlCreateTab(10, 10, 200, 100,$TCS_BUTTONS)
    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab1 = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    GUISetState()
    
    _GUICtrlTab_SetCurFocus($tab, 1)
    ;_GUICtrlTab_SetCurSel($tab, 1)
        
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            ExitLoop
            GUIDelete (-1)
        endif
    WEnd
EndFunc

Thanks for your reply, maybe someone else got a hint?

Cheers

Poly

Edit: Tweaked the code a little...

Edited by Polyphem

This post will be edited again by Polyphem: Tomorrow, 11:55 AM

Share this post


Link to post
Share on other sites
smashly

Is there any reason your not using GUICtrlSetState($tab1, $GUI_SHOW) ?

Share this post


Link to post
Share on other sites
Polyphem

Ehhhhh, yes.... i didnt know that that function works on tabs muttley... but it does :), thanks for the reply m8!

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

Example_Tab_without_TCS_BUTTONS()

Example_Tab_with_TCS_BUTTONS()

Func Example_Tab_without_TCS_BUTTONS()
    GUICreate("My GUI Tab", 250, 150)
    $tab = GUICtrlCreateTab(10, 10, 200, 100)
    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab1 = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    GUISetState()
    
    ;_GUICtrlTab_SetCurFocus($tab, 1)
    ;_GUICtrlTab_SetCurSel($tab, 1)
    GUICtrlSetState($tab1, $GUI_SHOW)
        
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            ExitLoop
            GUIDelete (-1)
        endif
    WEnd
EndFunc

Func Example_Tab_with_TCS_BUTTONS()
    GUICreate("My GUI Tab", 250, 150)
    $tab = GUICtrlCreateTab(10, 10, 200, 100,$TCS_BUTTONS)
    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab1 = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    GUISetState()
    
    ;_GUICtrlTab_SetCurFocus($tab, 1)
    ;_GUICtrlTab_SetCurSel($tab, 1)
    GUICtrlSetState($tab1, $GUI_SHOW)
        
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            ExitLoop
            GUIDelete (-1)
        endif
    WEnd
EndFunc

This post will be edited again by Polyphem: Tomorrow, 11:55 AM

Share this post


Link to post
Share on other sites
smashly

Your welcome

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  

×