pollardd 0 Posted April 14, 2007 Hi There, I'm trying to change the current tab in a tab control programatically. I have come up with a simple example of what I'm trying to do but can't get it to work. Either _GUICtrlTabSetCurFocus isn't the right command to use or I'm no using it right. Any ideas? David CODE#include <GUIConstants.au3> #include <GuiTab.au3> GUICreate("Tab Set Current Focus", 300, 200) ; will create a dialog box that when displayed is centered $tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE) $tab0 = GUICtrlCreateTabItem("Tab-Zero") $buttonzero = GUICtrlCreateButton("Goto Tab One", 200, 130, 90, 30) GUICtrlCreateTabItem("") ; end tabitem definition $tab1 = GUICtrlCreateTabItem("Tab-One") $buttonone = GUICtrlCreateButton("Goto Tab Two", 200, 130, 90, 30) GUICtrlCreateTabItem("") ; end tabitem definition $tab2 = GUICtrlCreateTabItem("Tab-Two") $buttontwo = GUICtrlCreateButton("Goto Tab Zero", 200, 130, 90, 30) GUICtrlCreateTabItem("") ; end tabitem definition GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $buttonzero _GUICtrlTabSetCurFocus($tab,$tab1) Case $msg = $buttonone _GUICtrlTabSetCurFocus($tab,$tab2) Case $msg = $buttontwo _GUICtrlTabSetCurFocus($tab,$tab0) EndSelect WEnd Share this post Link to post Share on other sites
Zedna 277 Posted April 14, 2007 Look at ControlCommand() & "CurrentTab", "TabLeft", "TabRight" commands. Also Auto3Lib has functions for Tab control, for example: _Tab_SetCurFocus($hWnd, $iIndex) _Tab_SetCurSel($hWnd, $iIndex) I think your problem is that you are using _GUICtrlTabSetCurFocus() instead of _GUICtrlTabSetCurSel() Resources UDF ResourcesEx UDF AutoIt Forum Search Share this post Link to post Share on other sites
pollardd 0 Posted April 19, 2007 Thanks that solved part of the problem. Now when I click on the tabs I see the different buttons but if I click on the button the tab changes but the previous button remains. Any ideas how come I don't see the correct buttons when the tabs change? David #include <GUIConstants.au3> #include <GuiTab.au3> GUICreate("Tab Set Current Focus", 300, 200) ; will create a dialog box that when displayed is centered $tab = GUICtrlCreateTab(10, 10, 285, 180, $TCS_MULTILINE) $tab0 = GUICtrlCreateTabItem("Tab-Zero") $buttonzero = GUICtrlCreateButton("Goto Tab One", 200, 130, 90, 30) GUICtrlCreateTabItem("") ; end tabitem definition $tab1 = GUICtrlCreateTabItem("Tab-One") $buttonone = GUICtrlCreateButton("Goto Tab Two", 200, 130, 90, 30) GUICtrlCreateTabItem("") ; end tabitem definition $tab2 = GUICtrlCreateTabItem("Tab-Two") $buttontwo = GUICtrlCreateButton("Goto Tab Zero", 200, 130, 90, 30) GUICtrlCreateTabItem("") ; end tabitem definition GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $buttonzero _GUICtrlTabSetCurSel($tab,1) Case $msg = $buttonone _GUICtrlTabSetCurSel($tab,2) Case $msg = $buttontwo _GUICtrlTabSetCurSel($tab,0) EndSelect WEnd Share this post Link to post Share on other sites
therks 33 Posted April 19, 2007 First: You don't need those lines like GUICtrlCreateTabItem("") after each tab, that's only meant for when you're completely done with the tabs (ie: you'd create a tab, put some controls in it, then create another tab, put more controls, then use that code to close the entire tab control, then put some more controls on the main GUI). Second: It looks like the _GUICtrlTabSetCurSel only changes the tab control visually, it doesn't refresh the actual control.. the remarks for the function note this: A tab control does not send a $TCN_SELCHANGING or $TCN_SELCHANGE notification message when a tab is selected using this message. Personally, I've always used GUICtrlSetState to set my tabs. Give this a try: #include <GUIConstants.au3> GUICreate("Tab Set Current Focus", 300, 200) ; will create a dialog box that when displayed is centered $tab = GUICtrlCreateTab(10, 10, 285, 180, $TCS_MULTILINE) $tab0 = GUICtrlCreateTabItem("Tab-Zero") $buttonzero = GUICtrlCreateButton("Goto Tab One", 200, 130, 90, 30) $tab1 = GUICtrlCreateTabItem("Tab-One") $buttonone = GUICtrlCreateButton("Goto Tab Two", 200, 130, 90, 30) $tab2 = GUICtrlCreateTabItem("Tab-Two") $buttontwo = GUICtrlCreateButton("Goto Tab Zero", 200, 130, 90, 30) GUICtrlCreateTabItem("") ; end tabitem definition GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $buttonzero GUICtrlSetState($tab1, $GUI_SHOW) Case $msg = $buttonone GUICtrlSetState($tab2, $GUI_SHOW) Case $msg = $buttontwo GUICtrlSetState($tab0, $GUI_SHOW) EndSelect WEnd My AutoIt Stuff | My Github Share this post Link to post Share on other sites
pollardd 0 Posted April 26, 2007 Sorry it took me so long to get back but I just though I'd let other people who may be reading this. IT WORKED The last suggestion did the trick. David Share this post Link to post Share on other sites