#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
$Debug_SB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
Local $hGUI, $hProgress, $hButton, $Button, $progress, $hStatus,$Msgbox
Local $aParts[4] = [80, 160, 300, -1]
$hGUI = GUICreate("StatusBar Embed Control", 400, 300)
$hStatus = _GUICtrlStatusBar_Create ($hGUI)
_GUICtrlStatusBar_SetMinHeight ($hStatus, 20)
GUISetState()
_GUICtrlStatusBar_SetParts ($hStatus, $aParts)
_GUICtrlStatusBar_SetText ($hStatus, "Part 1")
_GUICtrlStatusBar_SetText ($hStatus, "Part 2", 1)
_GUICtrlStatusBar_SetText ($hStatus, "Part 3", 2)
_GUICtrlStatusBar_SetText ($hStatus, "Part 4", 3)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
$Msgbox=GUIGetMsg()
Switch $Msgbox
Case $GUI_EVENT_CLOSE
GUIDelete()
Exit
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hStatus
Switch $iCode
Case $NM_CLICK ; 鼠标左键点击项目时由控件发送
$tInfo = DllStructCreate($tagNMMOUSE, $ilParam)
Select
Case DllStructGetData($tInfo, "ItemSpec")=0
MsgBox(0,0,"选中第一栏")
Case DllStructGetData($tInfo, "ItemSpec")=1
MsgBox(0,0,"选中第二栏")
Case DllStructGetData($tInfo, "ItemSpec")=2
MsgBox(0,0,"选中第三栏")
Case DllStructGetData($tInfo, "ItemSpec")=3
MsgBox(0,0,"选中第四栏")
EndSelect
Return TRUE ; 表示已获取鼠标点击并由系统禁止默认操作
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY