# Function Reference

# _GUICtrlStatusBar_GetText

Retrieves the text from the specified part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetText ( $hWnd, $iPart )

## Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

## Return Value

Success: | the part text.
Failure: | sets the @error flag to non-zero.
@error: | 2 - $hWnd is not a StatusBar control.

## Related

_GUICtrlStatusBar_SetText

## Example

### Example 1 use with icon handle

    #include "Extras\HelpFileInternals.au3"

    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>
    #include <WinAPIIcons.au3>

    Example()

    Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("StatusBar Get/Set Text (v" & @AutoItVersion & ")", 450, 320, 100, 100)
        Local $hStatus = _GUICtrlStatusBar_Create($hGUI)

        ; Create memo control
        _MemoCreate(2, 8, 444, 259)

        GUISetState(@SW_SHOW)

        ; Set parts
        Local $aParts[4] = [75, 150, 300, 400]
        _GUICtrlStatusBar_SetParts($hStatus, $aParts)
        _GUICtrlStatusBar_SetText($hStatus, "Part 0")
        _GUICtrlStatusBar_SetText($hStatus, "Part 1", 1)
        _GUICtrlStatusBar_SetText($hStatus, "Part 2", 2)
        _GUICtrlStatusBar_SetText($hStatus, "Part 3", 3)
        Local $iWrongSetText = _GUICtrlStatusBar_SetText($hStatus, "Wrong Part", 4)

        ; Set icons
        Local $ahIcons[2]
        $ahIcons[0] = _WinAPI_LoadShell32Icon(23)
        $ahIcons[1] = _WinAPI_LoadShell32Icon(40)
        _GUICtrlStatusBar_SetIcon($hStatus, 0, $ahIcons[0])
        _GUICtrlStatusBar_SetIcon($hStatus, 1, $ahIcons[1])

        ; Show part text
        _MemoWrite("Part 0 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 0))
        _MemoWrite("Part 1 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 1))

        ; Show icon handles
        _MemoWrite("Part 0 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
        _MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

        _MemoWrite("Wrong Part SetText .: " & $iWrongSetText)

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

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        ; Free icons
        _WinAPI_DestroyIcon($ahIcons[0])
        _WinAPI_DestroyIcon($ahIcons[1])
        GUIDelete()
    EndFunc   ;==>Example

### Example 2 : direct use with icon file

    #include "Extras\HelpFileInternals.au3"

    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>

    Example()

    Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("StatusBar Get/Set Text (v" & @AutoItVersion & ")", 450, 320, 100, 100)
        Local $hStatus = _GUICtrlStatusBar_Create($hGUI)

        ; Create memo control
        _MemoCreate(2, 8, 444, 259)
        GUISetState(@SW_SHOW)

        ; Set parts
        Local $aParts[4] = [75, 150, 300, 400]
        _GUICtrlStatusBar_SetParts($hStatus, $aParts)
        _GUICtrlStatusBar_SetText($hStatus, "Part 0")
        _GUICtrlStatusBar_SetText($hStatus, "Part 1", 1)
        _GUICtrlStatusBar_SetText($hStatus, "Part 2", 2)
        _GUICtrlStatusBar_SetText($hStatus, "Part 3", 3)

        ; Set icons
        _GUICtrlStatusBar_SetIcon($hStatus, 0, 23, "shell32.dll")
        _GUICtrlStatusBar_SetIcon($hStatus, 1, 40, "shell32.dll")

        ; Show part text
        _MemoWrite("Part 0 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 0))
        _MemoWrite("Part 1 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 1))

        ; Show icon handles
        _MemoWrite("Part 0 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
        _MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

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

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
    EndFunc   ;==>Example

### Example 3 : StatusBar Get/Set Text to an External process

    #include "Extras\HelpFileInternals.au3"

    #include <GuiStatusBar.au3>

    Example()

    Func Example()
        Local $sFromTo
        Local $hWin = _MemoRunAU3OutProcess($sFromTo)

        Local $hStatus = _MemoCreateOutProcess($hWin, "msctls_statusbar32", 0, $sFromTo)

        Local $iPart = 0
        _GUICtrlStatusBar_SetText($hStatus, "UPD 0", $iPart) ; update the external Process StatusBar part 0

        _MemoWrite(@CRLF & "=====================" & @CRLF & "StatusBar info displayed" & $sFromTo & " External process" & @CRLF & "=====================")
        ; Show part text
        _MemoWrite("Part " & $iPart & " text ........: " & _GUICtrlStatusBar_GetText($hStatus, $iPart))
        _MemoWrite("Parts count ........: " & _GUICtrlStatusBar_GetCount($hStatus))
        Local $aParts = _GUICtrlStatusBar_GetParts($hStatus)
        For $iI = 0 To $aParts[0] - 1
            _MemoWrite("Part " & $iI & " width .: " & _GUICtrlStatusBar_GetWidth($hStatus, $iI) & " (" & $aParts[$iI + 1] & ")")
        Next

        _MemoWrite(@CRLF & "=====================")

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

    EndFunc   ;==>Example