Function Reference


_GUICtrlButton_SetFocus

Sets the keyboard focus to the specified button

#include <GuiButton.au3>
_GUICtrlButton_SetFocus ( $hWnd [, $bFocus = True] )

Parameters

$hWnd Control ID/Handle to the control
$bFocus [optional] This parameter can be one of the following values:
    True - Sets the keyboard focus to the button
    False - Removes the keyboard focus from the button

Return Value

Success: True.
Failure: False.

Related

_GUICtrlButton_GetFocus

Example

#include "Extras\HelpFileInternals.au3"

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsStylesConstants.au3>

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk

    GUICreate("Buttons", 400, 400)
    _MemoCreate(119, 10, 276, 374, $WS_VSCROLL)

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)
    _GUICtrlButton_SetFocus($idRdo)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
    _GUICtrlButton_SetCheck($idRdo2)

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    GUISetState(@SW_SHOW)

    _MemoWrite(StringFormat("$idRdo focus status.: %s", _GUICtrlButton_GetFocus($idRdo)))
    _MemoWrite(StringFormat("$idRdo2 focus status: %s", _GUICtrlButton_GetFocus($idRdo2)))
    _MemoWrite(StringFormat("$idChk focus status.: %s", _GUICtrlButton_GetFocus($idChk)))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example