# Function Reference

# _GUICtrlTab_ActivateTab

Activates a tab by its index

#include <GuiTab.au3>
_GUICtrlTab_ActivateTab ( $hWnd, $iIndex )

## Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

## Return Value

Success: | the index of the previously selected tab.
Failure: | -1.

## Example

### Example 1 : Created with Native AutoIt functions

    #include "Extras\HelpFileInternals.au3"
    #include "Extras\WM_NOTIFY.au3"

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

    Example()

    Func Example()
        ; Create GUI
        local $hGUI = GUICreate("Tab ActivateTab (v" & @AutoItVersion & ")", 450, 300, 100, 100)
        Local $idTab = GUICtrlCreateTab(2, 2, 446, 266)
        _MemoMsgBoxStatus() ; Status creation

        GUISetState(@SW_SHOW)

        ; Add tabs
        GUICtrlCreateTabItem("Tab 0")
        GUICtrlCreateTabItem("Tab 1")
        GUICtrlCreateTabItem("Tab 2")

        _GUICtrlTab_ActivateTab($idTab, 1)
        _MemoMsgBox($MB_SYSTEMMODAL, "Information", "Tab 1 is activated")
        _GUICtrlTab_ActivateTab($idTab, 3)
        _MemoMsgBox($MB_SYSTEMMODAL, "Information", "Tab 3 does not exist")

        _MemoMsgBoxStatus("", -1, $hGUI) ; no more action, wait GUI for closing

    EndFunc   ;==>Example

### Example (OutProcess) : Tab ActivateTab to an External process

    #include "Extras\HelpFileInternals.au3"

    #include <GuiTab.au3>
    #include <MsgBoxConstants.au3>

    Example()

    Func Example()
        Local $sFromTo
        Local $hWin = _MemoRunAU3OutProcess($sFromTo, True) ; OK also if running in different mode
        Local $hTabCtrl = _MemoCreateOutProcess($hWin, "SysTabControl32", 2, $sFromTo)

        _GUICtrlTab_ActivateTab($hTabCtrl, 2)
        _MemoMsgBox($MB_SYSTEMMODAL, "Info" & $sFromTo, "Tab 2 is activated")

        _MemoMsgBoxStatus("", Default, $hWin) ; no more action, wait GUI for closing

    EndFunc   ;==>Example