Function Reference


_GUICtrlTab_SetCurSel

Selects a tab

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

Parameters

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

Return Value

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

Remarks

A tab control does not send a $TCN_SELCHANGING or $TCN_SELCHANGE notification message when a tab is selected using this function.

Related

_GUICtrlTab_DeselectAll, _GUICtrlTab_GetCurSel, _GUICtrlTab_HighlightItem

Example

#include "Extras\HelpFileInternals.au3"

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

Example()

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

    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 0")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 2")

    ; Get/Set current selection
    _MemoMsgBox($MB_SYSTEMMODAL, "Information", "Set Current Selection: #1")
    _GUICtrlTab_SetCurSel($idTab, 1)
    _MemoMsgBox($MB_SYSTEMMODAL, "Information", "Current Selection: #" & _GUICtrlTab_GetCurSel($idTab))

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

EndFunc   ;==>Example