# Function Reference

# GUISwitch

Switches the current window used for GUI functions.

GUISwitch ( winhandle [, tabitemID] )

## Parameters

winhandle | The handle of the window to switch to.
tabitemID | [optional] controlID of the tabitem control to be selected.

## Return Value

Success: | handle of the previous GUI.
Failure: | a null handle.

## Remarks

Many of the GUI specific functions work on the "current" window - this is usually the last window created with GUICreate(). This function allows you to make another window "current". That's does not mean that the referenced window will become active. You have to use WinActivate().
Using the tabitemID allow to create new control in the specified tabitem control. Don't forget to close tabitem definition GUICtrlCreateTabItem("")

## Related

GUICreate, GUICtrlCreateTabItem, GUIDelete

## Example

    #include <GUIConstantsEx.au3>

    Example()

    Func Example()
        Local $hGUIParent1 = GUICreate("Parent1")
        GUICtrlCreateTab(10, 10)
        Local $idTabItem = GUICtrlCreateTabItem("tab1")
        GUICtrlCreateTabItem("tab2")
        GUICtrlCreateTabItem("")

        Local $hGUIParent2 = GUICreate("Parent2", -1, -1, 100, 100)

        GUISwitch($hGUIParent2)
        GUISetState(@SW_SHOW)

        ; Loop until the user exits.
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    ExitLoop

            EndSwitch
        WEnd

        GUISwitch($hGUIParent1, $idTabItem)
        GUICtrlCreateButton("OK", 50, 50, 50)
        GUICtrlCreateTabItem("")

        GUISetState(@SW_SHOW, $hGUIParent1)
        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    ExitLoop
            EndSwitch
        WEnd

        GUIDelete($hGUIParent1)
        GUIDelete($hGUIParent2)
    EndFunc   ;==>Example