函数参考


_GUICtrlStatusBar_SetText

设置状态窗口指定部件的文本

#Include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetText($hWnd, $sText = "", $iPart = 0, $iUFlag = 0)

参数

$hWnd 控件句柄
$sText 部件的显示文本
$iPart 部件的保留文本
$iUFlag 绘制操作类型.类型可以是以下值:
0 - 绘制文本的边框低于窗口平面
$SBT_NOBORDERS - 绘制无边框文本
$SBT_OWNERDRAW - 由父窗口绘制文本
$SBT_POPOUT - 绘制文本的边框高于窗口平面
$SBT_RTLREADING - 文本反向显示到父窗口

返回值

成功: 返回 True
失败: 返回 False

注意/说明

 为简单状态条设置 $iPart 为 $SB_SIMPLEID

相关

_GUICtrlStatusBar_GetText

示例/演示


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

$Debug_SB = False ; 检查传递给函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作

Global $iMemo

Example1()
Example2()

Func Example1()

    Local $hGUI, $hIcons[2], $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; 创建 GUI
    $hGUI = GUICreate("(Example 1) StatusBar Set Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; 创建 memo 控件
    $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

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

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

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

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    _WinAPI_DestroyIcon($hIcons[0])
    _WinAPI_DestroyIcon($hIcons[1])
    GUIDelete()
EndFunc   ;==>Example1

Func Example2()

    Local $hGUI, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; 创建 GUI
    $hGUI = GUICreate("(Example 2) StatusBar Set Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; 创建 memo 控件
    $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

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

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

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

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example2

; 写入消息到 memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite