#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
Global $g_idMemo, $g_hMainGUI, $g_hStatus
Example()
Func Example()
Local $hGUI
Local $aText[3] = ["左对齐", @TAB & "居中", @TAB & @TAB & "右对齐"]
Local $aParts[3] = [100, 175, -1]
; 创建 GUI
$hGUI = GUICreate("(示例 3) 创建状态栏", 400, 300,-1,-1,BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX ,$WS_MAXIMIZEBOX ) )
;设置组件与文本
$g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts, $aText)
; 创建备忘录控件
$g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
MemoWrite("状态栏创建:" & @CRLF & _
@TAB & "句柄," & @CRLF & _
@TAB & "组件宽度数组, 3 个元素" & @CRLF & _
@TAB & "组件文本数组, 3 个元素" & @CRLF)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; 获取边框尺寸
MemoWrite("水平边框宽度 .: " & _GUICtrlStatusBar_GetBordersHorz($g_hStatus))
MemoWrite("垂直边框宽度 .: " & _GUICtrlStatusBar_GetBordersVert($g_hStatus))
MemoWrite("矩形宽度 .....: " & _GUICtrlStatusBar_GetBordersRect($g_hStatus))
; 循环到用户退出.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUISetState(@SW_ENABLE, $g_hMainGUI)
GUIDelete($hGUI)
EndFunc ;==>Example
; 写脚本运行消息到备忘录控件
Func MemoWrite($sMessage = "")
GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Local $tInfo
Switch $hWndFrom
Case $g_hStatus
Switch $iCode
Case $NM_CLICK ; 用户在控件范围内点击鼠标左键
$tInfo = DllStructCreate($tagNMMOUSE, $lParam)
$hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
$iIDFrom = DllStructGetData($tInfo, "IDFrom")
$iCode = DllStructGetData($tInfo, "Code")
_DebugPrint("$NM_CLICK" & @CRLF & "--> 控件句柄:" & @TAB & $hWndFrom & @CRLF & _
"-->控件 ID:" & @TAB & $iIDFrom & @CRLF & _
"-->操作代码:" & @TAB & $iCode & @CRLF & _
"-->项目规格:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
"-->项目数据:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
"-->X 坐标:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
"-->Y 坐标:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
"-->点击消息:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
Return True ; 处理鼠标点击, 制止系统默认处理
; Return FALSE ;允许默认处理点击操作.
Case $NM_DBLCLK ; 用户在控件内双击鼠标左键
$tInfo = DllStructCreate($tagNMMOUSE, $lParam)
$hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
$iIDFrom = DllStructGetData($tInfo, "IDFrom")
$iCode = DllStructGetData($tInfo, "Code")
_DebugPrint("$NM_DBLCLK" & @CRLF & "--> 控件句柄:" & @TAB & $hWndFrom & @CRLF & _
"-->控件 ID:" & @TAB & $iIDFrom & @CRLF & _
"-->操作代码:" & @TAB & $iCode & @CRLF & _
"-->项目规格:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
"-->项目数据:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
"-->X 坐标:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
"-->Y 坐标:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
"-->点击消息:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
Return True ; 处理鼠标点击, 制止系统默认处理
; Return FALSE ;允许默认处理点击操作.
Case $NM_RCLICK ; 用户在控件范围内单击鼠标右键
$tInfo = DllStructCreate($tagNMMOUSE, $lParam)
$hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
$iIDFrom = DllStructGetData($tInfo, "IDFrom")
$iCode = DllStructGetData($tInfo, "Code")
_DebugPrint("$NM_RCLICK" & @CRLF & "--> 控件句柄:" & @TAB & $hWndFrom & @CRLF & _
"-->控件 ID:" & @TAB & $iIDFrom & @CRLF & _
"-->操作代码:" & @TAB & $iCode & @CRLF & _
"-->项目规格:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
"-->项目数据:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
"-->X 坐标:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
"-->Y 坐标:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
"-->点击消息:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
Return True ; 处理鼠标点击, 制止系统默认处理
; Return FALSE ;允许默认处理点击操作.
Case $NM_RDBLCLK ; 用户在控件范围内双击鼠标右键
$tInfo = DllStructCreate($tagNMMOUSE, $lParam)
$hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
$iIDFrom = DllStructGetData($tInfo, "IDFrom")
$iCode = DllStructGetData($tInfo, "Code")
_DebugPrint("$NM_RDBLCLK" & @CRLF & "--> 控件句柄:" & @TAB & $hWndFrom & @CRLF & _
"-->控件 ID:" & @TAB & $iIDFrom & @CRLF & _
"-->操作代码:" & @TAB & $iCode & @CRLF & _
"-->项目规格:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
"-->项目数据:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
"-->X 坐标:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
"-->Y 坐标:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
"-->点击消息:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
Return True ; 处理鼠标点击, 制止系统默认处理
; Return FALSE ;允许默认处理点击操作.
Case $SBN_SIMPLEMODECHANGE ; 简单模式改变
_DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> 控件句柄:" & @TAB & $hWndFrom & @CRLF & _
"-->控件 ID:" & @TAB & $iIDFrom & @CRLF & _
"-->操作代码:" & @TAB & $iCode)
; 没有返回值
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @CRLF & _
"+======================================================" & @CRLF & _
"-->行号(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
"+======================================================" & @CRLF)
EndFunc ;==>_DebugPrint
; GUI 大小变化时, 调整状态栏
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam, $lParam
_GUICtrlStatusBar_Resize($g_hStatus)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE