#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>
Opt('MustDeclareVars', 1)
$Debug_SB = False ; 检查传递给函数的类名, 设置为True,并使用另一个控件句柄,看看它的工作.
_Main()
Func _Main()
Local $hGUI, $hProgress, $hInput, $input, $progress, $hStatus
Local $aParts[4] = [80, 160, 300, -1]
; 创建 GUI
$hGUI = GUICreate("嵌入子控件", 400, 300)
;===============================================================================
; 默认一个部件, 没有文本
$hStatus = _GUICtrlStatusBar_Create($hGUI)
_GUICtrlStatusBar_SetMinHeight($hStatus, 20)
;===============================================================================
GUISetState()
; 初始化部件
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "部件 1")
_GUICtrlStatusBar_SetText($hStatus, "部件 2", 1)
; 嵌入一个进度条
If @OSType = "WIN32_WINDOWS" Then
$progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
$hProgress = GUICtrlGetHandle($progress)
_GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
Else
$progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_MARQUEE) ; marquee 工作于 Win XP 及更高版本
$hProgress = GUICtrlGetHandle($progress)
_GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
_SendMessage($hProgress, $PBM_SETMARQUEE, True, 200) ; marquee 工作于 Win XP 及更高版本
EndIf
$input = GUICtrlCreateInput("嵌入的输入框", 0, 0)
$hInput = GUICtrlGetHandle($input)
_GUICtrlStatusBar_EmbedControl($hStatus, 3, $hInput, 3)
; 循环到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
|